Skip to content

Commit

Permalink
feat: support acrValues (#105)
Browse files Browse the repository at this point in the history
* feat: expose AuthConfig acr values

* chore: revert prettier changes

* chore: apply changes from code-review

* chore: revert changes to spec

* chore: adds test for acrValues

* chore: simplifies some stuff

---------

Co-authored-by: Jose <[email protected]>
Co-authored-by: Leonardo Chaia <[email protected]>
  • Loading branch information
3 people authored Jan 3, 2024
1 parent 3f9eb9f commit 4a2cc17
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion projects/angular-simple-oidc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-simple-oidc",
"version": "12.0.0-alpha",
"version": "12.0.1-alpha",
"description": "Angular Library implementing Open Id Connect specification. Code Flow, Refresh Tokens, Session Management, Discovery Document.",
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions projects/angular-simple-oidc/src/lib/config/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ export interface AuthConfig {
* `${window.location.protocol}//${window.location.host}${window.location.pathname}`
*/
baseUrl?: string;

/**
* The authentication context class reference parameters.
*/
acrValues?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,44 @@ describe('OidcCodeFlowClientService', () => {
preRedirectUrl: currentLocation
});
}));

it('Should generate the url using provided acr values', fakeAsync(() => {
const doc: Partial<DiscoveryDocument> = {
authorization_endpoint: 'http://idp/authorize'
};

discoveryDocSpy.and.returnValue(of(doc));

const urlResult = {
codeChallenge: 'challenge',
codeVerifier: 'verifier',
nonce: 'nonce',
state: 'state',
url: 'url'
};

tokenUrlSpy.createAuthorizeUrl.and.returnValue(urlResult);

const redirectUri = 'redirect';
const idTokenHint = 'id-token-hint';
const prompt = 'prompt';
const acrValues = 'needs=wifi'

codeFlowClient.generateCodeFlowMetadata({ redirectUri, idTokenHint, prompt, acrValues })
.subscribe();
flush();

expect(tokenUrlSpy.createAuthorizeUrl)
.toHaveBeenCalledWith(doc.authorization_endpoint, {
clientId: config.clientId,
responseType: 'code',
scope: config.scope,
redirectUri: redirectUri,
idTokenHint: idTokenHint,
prompt: prompt,
acrValues
});
}));
});

describe('Code Flow Callback', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class OidcCodeFlowClient {
clientId: config.clientId,
scope: config.scope,
responseType: 'code',
...config.acrValues && { acrValues: config.acrValues },
...params,
})),
take(1),
Expand Down

0 comments on commit 4a2cc17

Please sign in to comment.