Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api sso silent #1166

Merged
merged 17 commits into from Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/msal-core/src/UserAgentApplication.ts
Expand Up @@ -574,6 +574,27 @@ export class UserAgentApplication {
});
}

/**
* API interfacing idToken request when applications already have a session/hint acquired by authorization client applications
* @param request
*/
ssoSilent(request: AuthenticationParameters): Promise<AuthResponse> {
jasonnutter marked this conversation as resolved.
Show resolved Hide resolved
// throw an error on an empty request
if (!request) {
throw ClientConfigurationError.createEmptyRequestError();
}

// throw an error on no hints passed
if(!request.sid || !request.loginHint) {
jasonnutter marked this conversation as resolved.
Show resolved Hide resolved
throw ClientConfigurationError.createSsoSilentError();
}

return this.acquireTokenSilent({
...request,
scopes: [this.clientId]
});
}

/**
* Use this function to obtain a token before every call to the API / resource provider
*
Expand Down Expand Up @@ -639,6 +660,7 @@ export class UserAgentApplication {
this.logger.verbose("ADAL's idToken exists. Extracting login information from ADAL's idToken ");
serverAuthenticationRequest.populateQueryParams(account, null, adalIdTokenObject);
}

const userContainedClaims = request.claimsRequest || serverAuthenticationRequest.claimsValue;

let authErr: AuthError;
Expand Down
2 changes: 1 addition & 1 deletion lib/msal-core/src/error/ClientAuthError.ts
Expand Up @@ -59,7 +59,7 @@ export const ClientAuthErrorMessage = {
},
userLoginRequiredError: {
code: "user_login_error",
desc: "User login is required."
desc: "User login is required. For silent calls, request must contain either sid of login_hint"
},
userDoesNotExistError: {
code: "user_non_existent",
Expand Down
9 changes: 9 additions & 0 deletions lib/msal-core/src/error/ClientConfigurationError.ts
Expand Up @@ -81,6 +81,10 @@ export const ClientConfigurationErrorMessage = {
telemetryConfigError: {
code: "telemetry_config_error",
desc: "Telemetry config is not configured with required values"
},
ssoSilentError: {
code: "sso_silent_error",
desc: "request must contain either sid of login_hint"
jasonnutter marked this conversation as resolved.
Show resolved Hide resolved
jasonnutter marked this conversation as resolved.
Show resolved Hide resolved
}
};

Expand Down Expand Up @@ -169,4 +173,9 @@ export class ClientConfigurationError extends ClientAuthError {

return new ClientConfigurationError(code, `${desc} mising values: ${missingKeys.join(",")}`);
}

static createSsoSilentError(): ClientConfigurationError {
return new ClientConfigurationError(ClientConfigurationErrorMessage.ssoSilentError.code,
ClientConfigurationErrorMessage.ssoSilentError.desc);
}
}