Skip to content

Commit

Permalink
Exposing more Microsoft OAuth parameters (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinejaussoin authored Nov 2, 2022
1 parent 7bdb055 commit 448dec7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ This will run a demo version, which you can turn into a fully licenced version b

### Version 4.16.3

- TBD
- Exposing "tenant", "authorization url" and "token url" for Microsoft OAuth.
- Upgrading dependencies
- 🇩🇪 German language improvements

### Version 4.16.2

Expand Down
9 changes: 8 additions & 1 deletion backend/src/auth/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { MicrosoftStrategyOptions } from 'passport-microsoft';
import { OktaStrategyOptions } from 'passport-okta-oauth20';
import config from '../config';

type MicrosoftStrategyOptionsWithTenant = MicrosoftStrategyOptions & {
tenant: string | undefined;
};

const providers = ['twitter', 'google', 'github', 'slack', 'microsoft', 'okta'];

const CLIENT_ORIGIN = config.BASE_URL || 'http://localhost:3000';
Expand Down Expand Up @@ -61,11 +65,14 @@ export const SLACK_CONFIG =
}
: null;

export const MICROSOFT_CONFIG: MicrosoftStrategyOptions | null =
export const MICROSOFT_CONFIG: MicrosoftStrategyOptionsWithTenant | null =
config.MICROSOFT_KEY && config.MICROSOFT_SECRET
? {
clientID: config.MICROSOFT_KEY || '',
clientSecret: config.MICROSOFT_SECRET || '',
tenant: config.MICROSOFT_TENANT,
authorizationURL: config.MICROSOFT_AUTHORIZATION_URL,
tokenURL: config.MICROSOFT_TOKEN_URL,
callbackURL: microsoftURL,
scope: ['user.read'],
}
Expand Down
10 changes: 10 additions & 0 deletions backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ function defaultsNumber(key: string, defaultValue: number): number {
return parseInt(process.env[key]!);
}

function defaultsUndefined(key: string): string | undefined {
if (process.env[key] === undefined) {
return undefined;
}
return process.env[key]!;
}

const config: BackendConfig = {
LICENCE_KEY: defaults('LICENCE_KEY', ''),
SELF_HOSTED: defaultsBool('SELF_HOSTED', true),
Expand Down Expand Up @@ -81,6 +88,9 @@ const config: BackendConfig = {
SLACK_BOT_ENABLE: defaultsBool('SLACK_BOT_ENABLE', false),
MICROSOFT_KEY: defaults('MICROSOFT_KEY', ''),
MICROSOFT_SECRET: defaults('MICROSOFT_SECRET', ''),
MICROSOFT_TENANT: defaultsUndefined('MICROSOFT_TENANT'),
MICROSOFT_AUTHORIZATION_URL: defaultsUndefined('MICROSOFT_AUTHORIZATION_URL'),
MICROSOFT_TOKEN_URL: defaultsUndefined('MICROSOFT_TOKEN_URL'),
OKTA_AUDIENCE: defaults('OKTA_AUDIENCE', ''),
OKTA_KEY: defaults('OKTA_KEY', ''),
OKTA_SECRET: defaults('OKTA_SECRET', ''),
Expand Down
3 changes: 3 additions & 0 deletions backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export interface BackendConfig {
SLACK_BOT_ENABLE: boolean;
MICROSOFT_KEY: string;
MICROSOFT_SECRET: string;
MICROSOFT_TENANT: string | undefined;
MICROSOFT_AUTHORIZATION_URL: string | undefined;
MICROSOFT_TOKEN_URL: string | undefined;
OKTA_AUDIENCE: string;
OKTA_KEY: string;
OKTA_SECRET: string;
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/self-hosting/optionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ services:
SLACK_SECRET:
MICROSOFT_KEY:
MICROSOFT_SECRET:
MICROSOFT_TENANT: # This should generally not be set at all.
MICROSOFT_AUTHORIZATION_URL: # This should generally not be set at all.
MICROSOFT_TOKEN_URL: # This should generally not be set at all.
OKTA_AUDIENCE:
OKTA_KEY:
OKTA_SECRET:
Expand Down
3 changes: 3 additions & 0 deletions self-hosting/docker-compose.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ services:
SLACK_SECRET:
MICROSOFT_KEY:
MICROSOFT_SECRET:
MICROSOFT_TENANT: # This should generally not be set at all.
MICROSOFT_AUTHORIZATION_URL: # This should generally not be set at all.
MICROSOFT_TOKEN_URL: # This should generally not be set at all.
OKTA_AUDIENCE:
OKTA_KEY:
OKTA_SECRET:
Expand Down

0 comments on commit 448dec7

Please sign in to comment.