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

Added nonce and proper response type for OIDC requests. #1085

Merged
merged 1 commit into from
Dec 11, 2020
Merged
Changes from all commits
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
12 changes: 11 additions & 1 deletion src/services/oauthService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as ClientOAuth2 from "client-oauth2";
import * as Utils from "@paperbits/common";
import { HttpClient } from "@paperbits/common/http";
import { ISettingsProvider } from "@paperbits/common/configuration";
import { GrantTypes } from "./../constants";
Expand Down Expand Up @@ -89,13 +90,22 @@ export class OAuthService {
*/
public authenticateImplicit(backendUrl: string, authorizationServer: AuthorizationServer): Promise<string> {
const redirectUri = `${backendUrl}/signin-oauth/implicit/callback`;
const query = {
state: Utils.guid()
};

if (authorizationServer.scopes.includes("openid")) {
query["nonce"] = Utils.guid();
query["response_type"] = "id_token";
}

const oauthClient = new ClientOAuth2({
clientId: authorizationServer.clientId,
accessTokenUri: authorizationServer.tokenEndpoint,
authorizationUri: authorizationServer.authorizationEndpoint,
redirectUri: redirectUri,
scopes: authorizationServer.scopes
scopes: authorizationServer.scopes,
query: query
});

return new Promise((resolve, reject) => {
Expand Down