Skip to content

Commit

Permalink
Added nonce and proper response type for OIDC requests. (#1085)
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslonov authored Dec 11, 2020
1 parent 3ed0c3a commit 539b467
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit 539b467

Please sign in to comment.