Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Outlook](NAA) Sample showing how to pass user identity to network resource #924

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
528 changes: 528 additions & 0 deletions Samples/auth/Outlook-Add-in-SSO-NAA-Identity/.gitignore

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"ms-edgedevtools.vscode-edge-devtools",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"msoffice.microsoft-office-add-in-debugger"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
42 changes: 42 additions & 0 deletions Samples/auth/Outlook-Add-in-SSO-NAA-Identity/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Outlook Desktop (Edge Chromium)",
"type": "msedge",
"request": "attach",
"port": 9229,
"timeout": 600000,
"webRoot": "${workspaceRoot}",
"preLaunchTask": "Debug: Outlook Desktop",
"postDebugTask": "Stop Debug"
},
{
"name": "Outlook Desktop (Edge Legacy)",
"type": "office-addin",
"request": "attach",
"url": "https://localhost:3000/taskpane.html?_host_Info=Outlook$Win32$16.01$en-US$$$$0",
"port": 9222,
"timeout": 600000,
"webRoot": "${workspaceRoot}",
"preLaunchTask": "Debug: Outlook Desktop",
"postDebugTask": "Stop Debug"
},
{
"name": "Middle Tier (launch and attach)",
"type": "node",
"request": "attach",
"port": 8080,
"timeout": 600000,
"preLaunchTask": "Debug: Desktop",
"postDebugTask": "Stop Debug"
},
{
"name": "Middle Tier (attach to existing)",
"type": "node",
"request": "attach",
"port": 8080,
"timeout": 600000
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript"
]
}

186 changes: 186 additions & 0 deletions Samples/auth/Outlook-Add-in-SSO-NAA-Identity/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build (Development)",
"type": "npm",
"script": "build:dev",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"clear": true,
"panel": "shared",
"showReuseMessage": false
}
},
{
"label": "Build (Production)",
"type": "npm",
"script": "build",
"group": "build",
"presentation": {
"clear": true,
"panel": "shared",
"showReuseMessage": false
}
},
{
"label": "Debug: Desktop",
"type": "npm",
"script": "start",
"dependsOn": [
"Build (Development)"
],
"dependsOrder": "sequence",
"presentation": {
"clear": true,
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Debug: Excel Desktop",
"type": "shell",
"command": "npm",
"args": [
"run",
"start:desktop",
"--",
"--app",
"excel"
],
"dependsOn": [
"Build (Development)"
],
"dependsOrder": "sequence",
"presentation": {
"clear": true,
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Debug: Outlook Desktop",
"type": "shell",
"command": "npm",
"args": [
"run",
"start:desktop",
"--",
"--app",
"outlook"
],
"dependsOn": [
"Build (Development)"
],
"dependsOrder": "sequence",
"presentation": {
"clear": true,
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Debug: PowerPoint Desktop",
"type": "shell",
"command": "npm",
"args": [
"run",
"start:desktop",
"--",
"--app",
"powerpoint"
],
"dependsOn": [
"Build (Development)"
],
"dependsOrder": "sequence",
"presentation": {
"clear": true,
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Debug: Word Desktop",
"type": "shell",
"command": "npm",
"args": [
"run",
"start:desktop",
"--",
"--app",
"word"
],
"dependsOn": [
"Build (Development)"
],
"dependsOrder": "sequence",
"presentation": {
"clear": true,
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Dev Server",
"type": "npm",
"script": "dev-server",
"presentation": {
"clear": true,
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Install",
"type": "npm",
"script": "install",
"presentation": {
"clear": true,
"panel": "shared",
"showReuseMessage": false
},
"problemMatcher": []
},
{
"label": "Lint: Check for problems",
"type": "npm",
"script": "lint",
"problemMatcher": [
"$eslint-stylish"
]
},
{
"label": "Lint: Fix all auto-fixable problems",
"type": "npm",
"script": "lint:fix",
"problemMatcher": [
"$eslint-stylish"
]
},
{
"label": "Stop Debug",
"type": "npm",
"script": "stop",
"presentation": {
"clear": true,
"panel": "shared",
"showReuseMessage": false
},
"problemMatcher": []
},
{
"label": "Watch",
"type": "npm",
"script": "watch",
"presentation": {
"clear": true,
"panel": "dedicated"
},
"problemMatcher": []
}
]
}
27 changes: 27 additions & 0 deletions Samples/auth/Outlook-Add-in-SSO-NAA-Identity/API/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// This file is the main Node.js server file that defines the express middleware.

const express = require('express');
const morgan = require('morgan');
const cors = require('cors');
const apiRouter = require('./routes/index');

const app = express();

/**
* Enable CORS middleware. In production, modify as to allow only designated origins and methods.
* If you are using Azure App Service, we recommend removing the line below and configure CORS on the App Service itself.
*/
app.use(cors());

app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(morgan('dev'));

app.use('/api', apiRouter);

const port = process.env.PORT || 5000;

module.exports = app;
81 changes: 81 additions & 0 deletions Samples/auth/Outlook-Add-in-SSO-NAA-Identity/API/bin/www
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env node

/**
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('ssoapp:server');
var devCerts = require('office-addin-dev-certs');
var https = require('https');
var fs = require('fs');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '5000');
app.set('port', port);

/**
* Create HTTP server.
*/
startServer(app, port);

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}

return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

async function startServer(app, port) {
//if (process.env.NODE_ENV === 'development') {
const options = await devCerts.getHttpsServerOptions();
https.createServer(options, app).listen(port, () => console.log(`Server running on ${port}`));
// }
// else {
// app.listen(process.env.port || 1337, () => console.log(`Server listening on port 1337`));
// }
}
Loading