Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ba49410
Initial Commit
tnorling May 1, 2020
e5764bc
Merge branch 'dev' into cloud-discovery
tnorling May 13, 2020
d2bf765
Merge branch 'dev' into cloud-discovery
tnorling May 19, 2020
968c1b3
Merge branch 'authority-metadata-openid-perf' of https://github.com/A…
tnorling May 19, 2020
a9b9853
Move setup functions to Factory
tnorling May 19, 2020
e90cd4e
Update unit tests
tnorling May 20, 2020
c75b961
Merge branch 'authority-metadata-openid-perf' of https://github.com/A…
tnorling May 20, 2020
453bad8
Resolve lint errors
tnorling May 20, 2020
85d1736
Move validation of Authority to Factory
tnorling May 21, 2020
e0fc794
Add TrustedHostList getter
tnorling May 21, 2020
a190f8a
Update Error message
tnorling May 21, 2020
72e213b
Separate async network call
tnorling May 21, 2020
acebe0f
Fix Trusted Check
tnorling May 21, 2020
19ab0dd
Unit Tests
tnorling May 21, 2020
dc93c20
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling May 21, 2020
b179c4d
Move TrustedAuthority to its own class
tnorling May 22, 2020
4d11b85
Clean up test
tnorling May 22, 2020
ff06f8b
Fix context
tnorling May 22, 2020
79e8fce
Merge branch 'dev' into cloud-discovery
tnorling May 26, 2020
80c4b6d
Add tests
tnorling May 26, 2020
22b125e
Merge branch 'dev' into cloud-discovery
tnorling Jun 1, 2020
acb0a51
Initiate cloud discovery in Constructor
tnorling Jun 2, 2020
69c53db
Fix lint errors
tnorling Jun 2, 2020
bc50c5a
Fix tests
tnorling Jun 2, 2020
01212c6
Revert "Fix tests"
tnorling Jun 3, 2020
ea9fab0
Revert "Fix lint errors"
tnorling Jun 3, 2020
e645c9e
Revert "Initiate cloud discovery in Constructor"
tnorling Jun 3, 2020
6e098e3
Merge branch 'dev' into cloud-discovery
tnorling Jun 3, 2020
c0fa200
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Jun 15, 2020
2e16854
Addressing feedback
tnorling Jun 15, 2020
84dd6a2
Merge branch 'dev' into cloud-discovery
tnorling Jun 15, 2020
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
Prev Previous commit
Next Next commit
Merge branch 'dev' into cloud-discovery
  • Loading branch information
tnorling committed May 19, 2020
commit d2bf7656628ef2fa16710a6e292e3a018e876962
2 changes: 1 addition & 1 deletion lib/msal-angular/docs/0.x-1.x-upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The new `msal` configuration object takes a function for `system.logger` and `fr

## Angular 6+ and rxjs@6

MSAL Angular now expects that your application is built with `@angular/core@>=6`, `@angular/core@>=6`, `rxjs@6`, and `rxjs-compat` is no longer required.
MSAL Angular now expects that your application is built with `@angular/core@>=6`, `@angular/common@>=6`, `rxjs@6`. And `rxjs-compat` is no longer required.

Steps:
1. Install newer versions of Angular and rxjs: `npm install @angular/core @angular/common rxjs`
Expand Down
6 changes: 5 additions & 1 deletion lib/msal-browser/src/app/PublicClientApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
ServerError,
Authority,
AuthorityFactory,
InteractionRequiredAuthError
InteractionRequiredAuthError,
B2cAuthority
} from "@azure/msal-common";
import { Configuration, buildConfiguration } from "../config/Configuration";
import { BrowserStorage } from "../cache/BrowserStorage";
Expand Down Expand Up @@ -91,6 +92,9 @@ export class PublicClientApplication {
// Initialize the browser storage class.
this.browserStorage = new BrowserStorage(this.config.auth.clientId, this.config.cache);

// Initialize default authority instance
B2cAuthority.setKnownAuthorities(this.config.auth.knownAuthorities);

this.defaultAuthorityInstance = AuthorityFactory.createInstance(
this.config.auth.authority || "https://login.microsoftonline.com/common",
this.config.system.networkClient
Expand Down
2 changes: 1 addition & 1 deletion lib/msal-common/src/authority/AuthorityFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AuthorityFactory {

if (pathSegments.length && pathSegments[0].toLowerCase() === Constants.ADFS)
return AuthorityType.Adfs;
else if (Object.keys(B2cAuthority.B2CTrustedHostList).length)
else if (B2cAuthority.B2CTrustedHostList.length)
return AuthorityType.B2C;

// defaults to Aad
Expand Down
4 changes: 0 additions & 4 deletions lib/msal-common/src/client/SPAClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { StringUtils } from "../utils/StringUtils";
import { UrlString } from "../url/UrlString";
import { Account } from "../account/Account";
import { buildClientInfo } from "../account/ClientInfo";
import { B2cAuthority } from "../authority/B2cAuthority";

/**
* SPAClient class
Expand All @@ -39,9 +38,6 @@ export class SPAClient extends BaseClient {
constructor(configuration: ClientConfiguration) {
// Implement base module
super(configuration);

// Initialize default authority instance
B2cAuthority.setKnownAuthorities(this.config.authOptions.knownAuthorities);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions lib/msal-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ export { SPAClient } from "./client/SPAClient";
export { AuthorizationCodeClient } from "./client/AuthorizationCodeClient";
export { DeviceCodeClient } from "./client/DeviceCodeClient";
export { RefreshTokenClient } from "./client/RefreshTokenClient";
export { AuthOptions, SystemOptions, LoggerOptions, TelemetryOptions, DEFAULT_SYSTEM_OPTIONS } from "./config/ClientConfiguration";
export {
AuthOptions, SystemOptions, LoggerOptions, TelemetryOptions, DEFAULT_SYSTEM_OPTIONS
} from "./config/ClientConfiguration";
export { ClientConfiguration } from "./config/ClientConfiguration";
// Account
export { Account } from "./account/Account";
export { IdTokenClaims } from "./account/IdTokenClaims";
// Authority
export { Authority } from "./authority/Authority";
export { B2cAuthority } from "./authority/B2cAuthority";
export { AuthorityFactory } from "./authority/AuthorityFactory";
// Cache
export { ICacheStorage } from "./cache/ICacheStorage";
Expand Down Expand Up @@ -41,5 +44,7 @@ export { ServerError } from "./error/ServerError";
export { ClientAuthError, ClientAuthErrorMessage } from "./error/ClientAuthError";
export { ClientConfigurationError, ClientConfigurationErrorMessage } from "./error/ClientConfigurationError";
// Constants and Utils
export { Constants, PromptValue, TemporaryCacheKeys, PersistentCacheKeys } from "./utils/Constants";
export {
Constants, PromptValue, TemporaryCacheKeys, PersistentCacheKeys, Prompt, ResponseMode
} from "./utils/Constants";
export { StringUtils } from "./utils/StringUtils";
30 changes: 22 additions & 8 deletions lib/msal-common/src/request/AuthorizationCodeUrlRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
* Licensed under the MIT License.
*/

import { Prompt, ResponseMode } from "../utils/Constants";

/**
* @type AuthorizationCodeUrlRequest: Request object passed by user to retrieve a Code from the server (first leg of authorization code grant flow)
* @type AuthorizationCodeUrlRequest: Request object passed by user to retrieve a Code from the
* server (first leg of authorization code grant flow)
*/
export type AuthorizationCodeUrlRequest = {

Expand All @@ -20,15 +23,17 @@ export type AuthorizationCodeUrlRequest = {
scopes: Array<string>;

/**
* Url of the authority which the application acquires tokens from
* Url of the authority which the application acquires tokens from. Defaults to
* https://login.microsoftonline.com/common. If using the same authority for all request, authority should set
* on client application object and not request, to avoid resolving authority endpoints multiple times.
*/
authority?: string;

/**
* Specifies the method that should be used to send the authentication result to your app.
* Can be query, form_post, or fragment. If no value is passed in, it defaults to query.
*/
responseMode?: string;
responseMode?: ResponseMode;

/**
* Used to secure authorization code grant via Proof of Key for Code Exchange (PKCE).
Expand All @@ -37,8 +42,8 @@ export type AuthorizationCodeUrlRequest = {
codeChallenge?: string;

/**
* The method used to encode the code verifier for the code challenge parameter. Can be one
* of plain or S256. If excluded, code challenge is assumed to be plaintext. For more
* The method used to encode the code verifier for the code challenge parameter. Can be
* "plain" or "S256". If excluded, code challenge is assumed to be plaintext. For more
* information, see the PKCE RCF: https://tools.ietf.org/html/rfc7636
*/
codeChallengeMethod?: string;
Expand All @@ -53,8 +58,17 @@ export type AuthorizationCodeUrlRequest = {

/**
* Indicates the type of user interaction that is required.
*
* login: will force the user to enter their credentials on that request, negating single-sign on
*
* none: will ensure that the user isn't presented with any interactive prompt. if request can't be completed via
* single-sign on, the endpoint will return an interaction_required error
* consent: will the trigger the OAuth consent dialog after the user signs in, asking the user to grant permissions
* to the app
* select_account: will interrupt single sign-=on providing account selection experience listing all the accounts in
* session or any remembered accounts or an option to choose to use a different account
*/
prompt?: string;
prompt?: Prompt;

/**
* Can be used to pre-fill the username/email address field of the sign-in page for the user,
Expand All @@ -77,8 +91,8 @@ export type AuthorizationCodeUrlRequest = {
claims?: string;

/**
* A value included in the request that is also returned in the token response. A randomly
* generated unique value is typically used for preventing cross site request forgery attacks.
* A value included in the request that is returned in the id token. A randomly
* generated unique value is typically used to mitigate replay attacks.
*/
nonce?: string;

Expand Down
5 changes: 3 additions & 2 deletions lib/msal-common/src/request/DeviceCodeRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export type DeviceCodeRequest = {
cancel?: boolean;

/**
* URI of the authority from which MSAL will acquire the tokens from. If this value is not set, MSAL defaults
* to the authority used when configuring the PublicClientApplication.
* Url of the authority which the application acquires tokens from. Defaults to
* https://login.microsoftonline.com/common. If using the same authority for all request, authority should set
* on client application object and not request, to avoid resolving authority endpoints multiple times.
*/
authority?: string;
};
9 changes: 4 additions & 5 deletions lib/msal-common/src/server/RequestParameterBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* Licensed under the MIT License.
*/

import { AADServerParamKeys, SSOTypes } from "../utils/Constants";
import { Constants } from "../utils/Constants";
import { AADServerParamKeys, Constants, Prompt, ResponseMode, SSOTypes } from "../utils/Constants";
import { ScopeSet } from "../request/ScopeSet";
import { ClientConfigurationError } from "../error/ClientConfigurationError";

Expand All @@ -29,10 +28,10 @@ export class RequestParameterBuilder {
* add response_mode. defaults to query.
* @param responseMode
*/
addResponseMode(responseMode?: string): void {
addResponseMode(responseMode?: ResponseMode): void {
this.parameters.set(
AADServerParamKeys.RESPONSE_MODE,
encodeURIComponent((responseMode) ? responseMode : Constants.QUERY_RESPONSE_MODE)
encodeURIComponent((responseMode) ? responseMode : ResponseMode.QUERY)
);
}

Expand Down Expand Up @@ -100,7 +99,7 @@ export class RequestParameterBuilder {
* add prompt
* @param prompt
*/
addPrompt(prompt: string): void {
addPrompt(prompt: Prompt): void {
this.parameters.set(`${AADServerParamKeys.PROMPT}`, encodeURIComponent(prompt));
}

Expand Down
31 changes: 21 additions & 10 deletions lib/msal-common/src/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const Constants = {
CODE_GRANT_TYPE: "authorization_code",
RT_GRANT_TYPE: "refresh_token",
FRAGMENT_RESPONSE_MODE: "fragment",
QUERY_RESPONSE_MODE: "query",
S256_CODE_CHALLENGE_METHOD: "S256",
URL_FORM_CONTENT_TYPE: "application/x-www-form-urlencoded;charset=utf-8",
AUTHORIZATION_PENDING: "authorization_pending"
Expand All @@ -45,7 +44,7 @@ export const Constants = {
*/
export enum HeaderNames {
CONTENT_TYPE = "Content-Type"
};
}

/**
* Temporary cache keys for MSAL, deleted after any request.
Expand All @@ -61,7 +60,7 @@ export enum TemporaryCacheKeys {
URL_HASH = "urlHash",
REQUEST_PARAMS = "request.params",
SCOPES = "scopes"
};
}

/**
* Persistent cache keys MSAL which stay while user is logged in.
Expand All @@ -72,7 +71,7 @@ export enum PersistentCacheKeys {
ADAL_ID_TOKEN = "adal.idtoken",
ERROR = "error",
ERROR_DESC = "error.description"
};
}

/**
* List of pre-established trusted host URLs.
Expand All @@ -93,7 +92,7 @@ export enum AADAuthorityConstants {
COMMON = "common",
ORGANIZATIONS = "organizations",
CONSUMERS = "consumers"
};
}

/**
* Keys in the hashParams sent by AAD Server
Expand Down Expand Up @@ -129,7 +128,7 @@ export enum AADServerParamKeys {
X_CLIENT_CPU = "x-client-CPU",
POST_LOGOUT_URI = "post_logout_redirect_uri",
DEVICE_CODE = "device_code"
};
}

/**
* IdToken claim string constants
Expand Down Expand Up @@ -168,13 +167,13 @@ export enum SSOTypes {
ACCOUNT = "account",
SID = "sid",
LOGIN_HINT = "login_hint",
ID_TOKEN ="id_token",
ID_TOKEN = "id_token",
DOMAIN_HINT = "domain_hint",
ORGANIZATIONS = "organizations",
CONSUMERS = "consumers",
ACCOUNT_ID = "accountIdentifier",
HOMEACCOUNT_ID = "homeAccountIdentifier"
};
}

/**
* Disallowed extra query parameters.
Expand All @@ -193,7 +192,9 @@ export const CodeChallengeMethodValues = {
};

/**
*
* The method used to encode the code verifier for the code challenge parameter. can be one
* of plain or s256. if excluded, code challenge is assumed to be plaintext. for more
* information, see the pkce rcf: https://tools.ietf.org/html/rfc7636
*/
export const CodeChallengeMethodValuesArray: string[] = [
CodeChallengeMethodValues.PLAIN,
Expand All @@ -209,6 +210,16 @@ export enum ResponseMode {
FORM_POST = "form_post"
}

/**
* Allowed values for prompt
*/
export enum Prompt {
LOGIN = "login",
NONE = "none",
CONSENT = "consent",
SELECT_ACCOUNT = "select_account"
}

/**
* allowed grant_type
*/
Expand All @@ -219,5 +230,5 @@ export enum GrantType {
RESOURCE_OWNER_PASSWORD_GRANT = "password",
REFRESH_TOKEN_GRANT = "refresh_token",
DEVICE_CODE_GRANT = "device_code"
};
}

4 changes: 2 additions & 2 deletions lib/msal-common/test/client/AuthorizationCodeClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("AuthorizationCodeClient unit tests", () => {
expect(loginUrl).to.contain(`${AADServerParamKeys.RESPONSE_TYPE}=${Constants.CODE_RESPONSE_TYPE}`);
expect(loginUrl).to.contain(`${AADServerParamKeys.CLIENT_ID}=${TEST_CONFIG.MSAL_CLIENT_ID}`);
expect(loginUrl).to.contain(`${AADServerParamKeys.REDIRECT_URI}=${encodeURIComponent(TEST_URIS.TEST_REDIRECT_URI_LOCALHOST)}`);
expect(loginUrl).to.contain(`${AADServerParamKeys.RESPONSE_MODE}=${encodeURIComponent(Constants.QUERY_RESPONSE_MODE)}`);
expect(loginUrl).to.contain(`${AADServerParamKeys.RESPONSE_MODE}=${encodeURIComponent(ResponseMode.QUERY)}`);
});

it("Creates an authorization url passing in a default scope", async () => {
Expand All @@ -78,7 +78,7 @@ describe("AuthorizationCodeClient unit tests", () => {
expect(loginUrl).to.contain(`${AADServerParamKeys.RESPONSE_TYPE}=${Constants.CODE_RESPONSE_TYPE}`);
expect(loginUrl).to.contain(`${AADServerParamKeys.CLIENT_ID}=${TEST_CONFIG.MSAL_CLIENT_ID}`);
expect(loginUrl).to.contain(`${AADServerParamKeys.REDIRECT_URI}=${encodeURIComponent(TEST_URIS.TEST_REDIRECT_URI_LOCALHOST)}`);
expect(loginUrl).to.contain(`${AADServerParamKeys.RESPONSE_MODE}=${encodeURIComponent(Constants.QUERY_RESPONSE_MODE)}`)
expect(loginUrl).to.contain(`${AADServerParamKeys.RESPONSE_MODE}=${encodeURIComponent(ResponseMode.QUERY)}`);
});

it("Creates an authorization url passing in optional parameters", async () => {
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.