Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
ADFS support
  • Loading branch information
Santiago Gonzalez committed May 7, 2020
commit fada900bcdd81f176045e1cd6673ee4314b4c315
32 changes: 32 additions & 0 deletions lib/msal-common/src/authority/AdfsAuthority.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import { Authority } from "./Authority";
import { AuthorityType } from "./AuthorityType";
import { INetworkModule } from "../network/INetworkModule";

/**
* The AadAuthority class extends the Authority class and adds functionality specific to the Azure AD OAuth Authority.
*/
export class AdfsAuthority extends Authority {

/**
* Return authority type
*/
public get authorityType(): AuthorityType {
return AuthorityType.Adfs;
}

public constructor(authority: string, networkInterface: INetworkModule) {
super(authority, networkInterface);
}

/**
* Returns a promise which resolves to the OIDC endpoint
*/
public async getOpenIdConfigurationEndpointAsync(): Promise<string> {
return `${this.canonicalAuthority}.well-known/openid-configuration`;
}
}
6 changes: 4 additions & 2 deletions lib/msal-common/src/authority/AuthorityFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import { INetworkModule } from "./../network/INetworkModule";
import { StringUtils } from "./../utils/StringUtils";
import { UrlString } from "./../url/UrlString";
import { Constants } from "../utils/Constants";
import { AdfsAuthority } from "./AdfsAuthority";

export class AuthorityFactory {
export class AuthorityFactory {

/**
* Parse the url and determine the type of authority
Expand Down Expand Up @@ -49,7 +50,8 @@ export class AuthorityFactory {
return new AadAuthority(authorityUrl, networkInterface);
case AuthorityType.B2C:
return new B2cAuthority(authorityUrl, networkInterface);
// TODO: Support ADFS here in a later PR
case AuthorityType.Adfs:
return new AdfsAuthority(authorityUrl, networkInterface);
default:
throw ClientAuthError.createInvalidAuthorityTypeError(`${authorityUrl}`);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/msal-common/src/client/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Logger } from "../logger/Logger";
import { AADServerParamKeys, Constants, HeaderNames } from "../utils/Constants";
import { NetworkResponse } from "../network/NetworkManager";
import { ServerAuthorizationTokenResponse } from "../server/ServerAuthorizationTokenResponse";
import { B2cAuthority } from "../authority/B2cAuthority";

/**
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
Expand Down Expand Up @@ -63,7 +64,8 @@ export abstract class BaseClient {
// Set the network interface
this.networkClient = this.config.networkInterface;

// Default authority instance.
B2cAuthority.setKnownAuthorities(this.config.authOptions.knownAuthorities);

this.defaultAuthority = this.config.authOptions.authority;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/msal-common/src/client/RefreshTokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class RefreshTokenClient extends BaseClient {

const scopeSet = new ScopeSet(request.scopes || [],
this.config.authOptions.clientId,
true);
false);
parameterBuilder.addScopes(scopeSet);
parameterBuilder.addClientId(this.config.authOptions.clientId);
parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
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