Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
06a744b
Initial Commit
tnorling May 15, 2020
f6fefcd
Create clientInfo from idToken
tnorling May 15, 2020
69e40cb
Merge branch 'cloud-discovery' of https://github.com/AzureAD/microsof…
tnorling May 27, 2020
56fdfdd
Update default type
tnorling May 27, 2020
10335de
Update Sample Readmes
tnorling May 27, 2020
520a465
Update package name for sample
tnorling May 27, 2020
c2ccdec
Merge branch 'cloud-discovery' of https://github.com/AzureAD/microsof…
tnorling Jun 3, 2020
00873a3
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Jun 3, 2020
93549a4
Strip Policy from UID
tnorling Jun 4, 2020
ccb09e7
Update policy strip logic
tnorling Jun 4, 2020
d8862d5
Sample
tnorling Jun 4, 2020
35ad895
Update with lab app registration
tnorling Jun 5, 2020
167ca67
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Jun 15, 2020
47d0a87
Update AuthorityType logic
tnorling Jun 15, 2020
336fc2a
Remove sample
tnorling Jun 15, 2020
c88a12e
Move isAdfs to Authority class
tnorling Jun 15, 2020
661f000
Unit tests
tnorling Jun 15, 2020
3b9c058
Add tests
tnorling Jun 16, 2020
5197bc4
Add upn as backup for username
tnorling Jun 16, 2020
76b1685
Revert "Add upn as backup for username"
tnorling Jun 16, 2020
c969187
Add upn as backup for username
tnorling Jun 16, 2020
c91e0f0
Merge branch 'dev' into b2c-multiple-policies
tnorling Jun 16, 2020
456ba37
Remove samples, will be added in different PR
tnorling Jun 16, 2020
5a5472b
Address Feedback
tnorling Jun 16, 2020
5398cca
Update to ternary
tnorling Jun 16, 2020
dfa6f5d
Update lib/msal-core/src/ClientInfo.ts
tnorling Jun 17, 2020
6114764
Merge branch 'msal-core-adfs' of https://github.com/AzureAD/microsoft…
tnorling Jun 17, 2020
a283256
Add sample + E2E
tnorling Jun 17, 2020
afd59f0
Update testRunner and LabClient
tnorling Jun 17, 2020
9b29939
Merge branch 'dev' into msal-core-adfs
tnorling Jun 17, 2020
4a6d1d3
Merge branch 'msal-core-adfs' of https://github.com/AzureAD/microsoft…
tnorling Jun 17, 2020
85a990a
Add readme to sample
tnorling Jun 22, 2020
c8c7a1e
Update server port
tnorling Jun 23, 2020
ab12b92
Update samples/VanillaJSTestApp/app/adfs/Readme.md
tnorling Jun 23, 2020
88c9132
Addressing feedback
tnorling Jun 24, 2020
6a962d5
Merge branch 'adfs-sample' of https://github.com/AzureAD/microsoft-au…
tnorling Jun 24, 2020
c1b8d1a
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Jul 7, 2020
4a664b9
Fix linting
tnorling Jul 7, 2020
176334f
Merge branch 'dev' into msal-core-adfs
tnorling Jul 25, 2020
2201bd3
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Aug 10, 2020
f674871
Cleanup
tnorling Aug 10, 2020
b861e2d
Update FAQ
tnorling Aug 10, 2020
553a623
Merge branch 'dev' into msal-core-adfs
tnorling Aug 11, 2020
63bac81
Change files
tnorling Aug 12, 2020
c08165c
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Aug 12, 2020
91dc3ac
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Aug 12, 2020
b082274
Tests passing
tnorling Aug 12, 2020
d5548a1
Change files
tnorling Aug 12, 2020
c400722
Merge branch 'dev' into msal-core-adfs
tnorling Aug 17, 2020
5f10555
Merge pull request #1668 from AzureAD/msal-core-adfs
tnorling Aug 17, 2020
30f7b66
Merge branch '1.4.0-release' of https://github.com/AzureAD/microsoft-…
tnorling Aug 17, 2020
603c101
[msal-core] Fix response type configuration by basing it mainly on sc…
Aug 17, 2020
cefd4ca
Merge branch '1.4.0-release' of https://github.com/AzureAD/microsoft-…
tnorling Aug 17, 2020
3782c0b
Update test
tnorling Aug 17, 2020
364621d
Update samples/VanillaJSTestApp/app/adfs/Readme.md
tnorling Aug 17, 2020
4fcdb41
Update welcome message
tnorling Aug 17, 2020
f5378d3
Merge branch 'adfs-sample' of https://github.com/AzureAD/microsoft-au…
tnorling Aug 17, 2020
c4fc53c
Add federationProvider to LabClient
tnorling Aug 17, 2020
2e2116d
Merge pull request #1791 from AzureAD/adfs-sample
tnorling Aug 18, 2020
065b8d8
Fix heading
tnorling Aug 18, 2020
83746d1
Update lib/msal-core/docs/FAQ.md
tnorling Aug 18, 2020
2be68fb
Merge branch '1.4.0-release' of https://github.com/AzureAD/microsoft-…
tnorling Aug 18, 2020
148fa9b
Address Feedback
tnorling Aug 18, 2020
9c011d5
Tests passing
tnorling Aug 19, 2020
f10c797
Merge pull request #1757 from AzureAD/b2c-multiple-policies
tnorling Aug 19, 2020
649a731
[msal-core] Fix invalid state issue by removing second layer of URL d…
Aug 20, 2020
c45ccd5
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Aug 24, 2020
efcfbb2
Update SRI hashes
tnorling Aug 24, 2020
2985cc2
Merge branch 'dev' into 1.4.0-release
tnorling Aug 24, 2020
552edd5
Merge branch 'dev' into 1.4.0-release
tnorling Aug 24, 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
…tion-library-for-js into msal-core-adfs
  • Loading branch information
tnorling committed Jun 15, 2020
commit 167ca678af6cd7ac9cd9876b2ac36c4169bceda9
27 changes: 16 additions & 11 deletions lib/msal-browser/src/app/PublicClientApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@
*/
import {
Account,
AuthenticationParameters,
Authority,
AuthorityFactory, ClientAuthError,
INetworkModule,
PromptValue,
ServerError,
SPAClient,
StringUtils,
TemporaryCacheKeys,
TokenRenewParameters,
INetworkModule,
TokenResponse,
UrlString,
AuthorityType,
TokenRenewParameters,
StringUtils,
PromptValue,
ServerError,
Authority,
AuthorityFactory,
InteractionRequiredAuthError,
B2cAuthority,
InteractionRequiredAuthError
AuthorizationUrlRequest,
PersistentCacheKeys,
IdToken,
ProtocolUtils,
AuthorizationCodeRequest,
Constants,
ClientAuthError,
AuthorityType
} from "@azure/msal-common";
import { buildConfiguration, Configuration } from "../config/Configuration";
import { BrowserStorage } from "../cache/BrowserStorage";
Expand Down
35 changes: 3 additions & 32 deletions lib/msal-browser/test/client/PublicClientApplication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,10 @@ chai.use(chaiAsPromised);
const expect = chai.expect;
import sinon from "sinon";
import { PublicClientApplication } from "../../src/app/PublicClientApplication";
import {
TEST_CONFIG,
TEST_URIS,
TEST_HASHES,
TEST_TOKENS,
TEST_DATA_CLIENT_INFO,
TEST_TOKEN_LIFETIMES,
RANDOM_TEST_GUID,
DEFAULT_OPENID_CONFIG_RESPONSE,
testNavUrl,
testLogoutUrl
} from "../utils/StringConstants";
import {
AuthError,
ServerError,
AuthResponse,
LogLevel,
Constants,
TemporaryCacheKeys,
TokenResponse,
Account,
TokenExchangeParameters,
IdTokenClaims,
SPAClient,
PromptValue,
AuthenticationParameters, ClientAuthError, ClientAuthErrorMessage
} from "@azure/msal-common";
import { TEST_CONFIG, TEST_URIS, TEST_HASHES, TEST_TOKENS, TEST_DATA_CLIENT_INFO, TEST_TOKEN_LIFETIMES, RANDOM_TEST_GUID, DEFAULT_OPENID_CONFIG_RESPONSE, testNavUrl, testLogoutUrl } from "../utils/StringConstants";
import { AuthError, ServerError, LogLevel, Constants, TokenResponse, Account, IdTokenClaims, SPAClient, PromptValue, AuthenticationResult, AuthorizationCodeRequest, AuthorizationUrlRequest, IdToken, PersistentCacheKeys, TokenRenewParameters, ClientAuthErrorMessage } from "@azure/msal-common";
import { AuthCallback } from "../../src/types/AuthCallback";
import {
BrowserConfigurationAuthErrorMessage,
BrowserConfigurationAuthError
} from "../../src/error/BrowserConfigurationAuthError";
import sinon from "sinon";
import { BrowserConfigurationAuthErrorMessage, BrowserConfigurationAuthError } from "../../src/error/BrowserConfigurationAuthError";
import { BrowserUtils } from "../../src/utils/BrowserUtils";
import { BrowserConstants, TemporaryCacheKeys } from "../../src/utils/BrowserConstants";
import { Base64Encode } from "../../src/encode/Base64Encode";
Expand Down
90 changes: 29 additions & 61 deletions lib/msal-common/src/client/SPAClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ 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";
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
import { RequestParameterBuilder } from "../server/RequestParameterBuilder";
import { AuthorizationCodeRequest } from "../request/AuthorizationCodeRequest";
import { RefreshTokenRequest } from "../request/RefreshTokenRequest";
import { AuthorityType } from "../authority/AuthorityType";

/**
Expand Down Expand Up @@ -145,52 +150,10 @@ export class SPAClient extends BaseClient {
* also use the handleFragmentResponse() API to pass the codeResponse to this function afterwards.
* @param codeResponse
*/
async acquireToken(codeResponse: CodeResponse): Promise<TokenResponse> {
try {
// If no code response is given, we cannot acquire a token.
if (!codeResponse || StringUtils.isEmpty(codeResponse.code)) {
throw ClientAuthError.createTokenRequestCannotBeMadeError();
}

// Get request from cache
const tokenRequest: TokenExchangeParameters = this.getCachedRequest(codeResponse.userRequestState);

// Initialize authority or use default, and perform discovery endpoint check.
const acquireTokenAuthority = (tokenRequest && tokenRequest.authority) ? AuthorityFactory.createInstance(tokenRequest.authority, this.networkClient) : this.defaultAuthority;

// This is temporary. Remove when ADFS is supported for browser
if(acquireTokenAuthority.authorityType == AuthorityType.Adfs){
throw ClientAuthError.createInvalidAuthorityTypeError(acquireTokenAuthority.canonicalAuthority);
}

if (!acquireTokenAuthority.discoveryComplete()) {
try {
await acquireTokenAuthority.resolveEndpointsAsync();
} catch (e) {
throw ClientAuthError.createEndpointDiscoveryIncompleteError(e);
}
}

// Get token endpoint.
const { tokenEndpoint } = acquireTokenAuthority;
// Initialize request parameters.
const tokenReqParams = new ServerTokenRequestParameters(
this.config.authOptions.clientId,
tokenRequest,
codeResponse,
this.getRedirectUri(),
this.cryptoUtils
);

// User helper to retrieve token response.
// Need to await function call before return to catch any thrown errors.
// if errors are thrown asynchronously in return statement, they are caught by caller of this function instead.
return await this.getTokenResponse(tokenEndpoint, tokenReqParams, tokenRequest, codeResponse);
} catch (e) {
// Reset cache items and set account to null before re-throwing.
this.spaCacheManager.resetTempCacheItems(codeResponse && codeResponse.userRequestState);
this.account = null;
throw e;
async acquireToken(codeRequest: AuthorizationCodeRequest, userState: string, cachedNonce: string): Promise<TokenResponse> {
// If no code response is given, we cannot acquire a token.
if (!codeRequest || StringUtils.isEmpty(codeRequest.code)) {
throw ClientAuthError.createTokenRequestCannotBeMadeError();
}

// Initialize authority or use default, and perform discovery endpoint check.
Expand Down Expand Up @@ -269,21 +232,26 @@ export class SPAClient extends BaseClient {
}
}

// Initialize authority or use default, and perform discovery endpoint check.
const acquireTokenAuthority = request.authority ? AuthorityFactory.createInstance(request.authority, this.networkClient) : this.defaultAuthority;

// This is temporary. Remove when ADFS is supported for browser
if(acquireTokenAuthority.authorityType == AuthorityType.Adfs){
throw ClientAuthError.createInvalidAuthorityTypeError(acquireTokenAuthority.canonicalAuthority);
}

if (!acquireTokenAuthority.discoveryComplete()) {
try {
await acquireTokenAuthority.resolveEndpointsAsync();
} catch (e) {
throw ClientAuthError.createEndpointDiscoveryIncompleteError(e);
}
}
// Get current cached tokens
const cachedTokenItem = this.getCachedTokens(requestScopes, acquireTokenAuthority.canonicalAuthority, account && account.homeAccountIdentifier);
const expirationSec = Number(cachedTokenItem.value.expiresOnSec);
const offsetCurrentTimeSec = TimeUtils.nowSeconds() + this.config.systemOptions.tokenRenewalOffsetSeconds;
// Check if refresh is forced, or if tokens are expired. If neither are true, return a token response with the found token entry.
if (!forceRefresh && expirationSec && expirationSec > offsetCurrentTimeSec) {
const cachedScopes = ScopeSet.fromString(cachedTokenItem.key.scopes, this.config.authOptions.clientId, true);
const defaultTokenResponse: TokenResponse = {
uniqueId: "",
tenantId: "",
scopes: cachedScopes.asArray(),
tokenType: cachedTokenItem.value.tokenType,
idToken: "",
idTokenClaims: null,
accessToken: cachedTokenItem.value.accessToken,
refreshToken: cachedTokenItem.value.refreshToken,
expiresOn: new Date(expirationSec * 1000),
account: account,
userRequestState: ""
};

// Only populate id token if it exists in cache item.
return StringUtils.isEmpty(cachedTokenItem.value.idToken) ? defaultTokenResponse :
Expand Down
2 changes: 1 addition & 1 deletion lib/msal-core/src/authority/Authority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { UrlUtils } from "../utils/UrlUtils";
import TelemetryManager from "../telemetry/TelemetryManager";
import HttpEvent from "../telemetry/HttpEvent";
import { TrustedAuthority } from "./TrustedAuthority";
import { Constants } from '../utils/Constants';
import { Constants, NetworkRequestType } from "../utils/Constants";

/**
* @hidden
Expand Down
2 changes: 1 addition & 1 deletion lib/msal-core/src/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Constants {
static get renewToken(): string { return "RENEW_TOKEN"; }
static get unknown(): string { return "UNKNOWN"; }

static get ADFS(): string { return "adfs"};
static get ADFS(): string { return "adfs"; };

static get homeAccountIdentifier(): string { return "homeAccountIdentifier"; }

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.