Skip to content
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
2 changes: 2 additions & 0 deletions callautomation-live-transcription/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { config } from 'dotenv';
import express, { Application } from 'express';
import http from 'http';
import helmet from 'helmet'; // Import helmet for security headers
import { PhoneNumberIdentifier, createIdentifierFromRawId } from "@azure/communication-common";
import {
CallAutomationClient, CallConnection, AnswerCallOptions, CallMedia,
Expand All @@ -21,6 +22,7 @@ config();
const PORT = process.env.PORT;
const app: Application = express();
app.use(express.json());
app.use(helmet()); // Use helmet to secure Express app by setting various HTTP headers

// Create common server for app and websocket
const server = http.createServer(app);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

require('dotenv').config({path: __dirname + '/.env' })
const { CommunicationIdentityClient } = require('@azure/communication-identity');
const { PublicClientApplication, CryptoProvider } = require('@azure/msal-node');
Expand Down Expand Up @@ -80,8 +79,8 @@ app.get('/redirect', async (req, res) => {
res.sendStatus(200);
}).catch((error) => {
console.log(error);
res.status(500).send(error);
res.status(500).send('An error occurred while processing your request.');
});
});

app.listen(SERVER_PORT, () => console.log(`Communication access token application started on ${SERVER_PORT}!`))
app.listen(SERVER_PORT, () => console.log(`Communication access token application started on ${SERVER_PORT}!`))
10 changes: 10 additions & 0 deletions tpe-token-and-access-management/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@ const cors = require('cors');
const path = require('path');
const config = require('./config');
const TeamsExtensionAccessManager = require('./teams-extension-access-manager');
const helmet = require('helmet'); // Added Helmet for security headers
const rateLimit = require('express-rate-limit'); // Added rate limiting

const app = express();
const PORT = config.server.port;

// Middleware
app.use(helmet()); // Use Helmet to secure the app by setting various HTTP headers
app.use(cors());
app.use(express.json());
app.use(express.static(path.join(__dirname, '..', 'dist')));

// Rate limiting middleware
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100 // Limit each IP to 100 requests per windowMs
});
app.use(limiter); // Apply rate limiting to all requests

// Initialize manager
const accessManager = new TeamsExtensionAccessManager();

Expand Down