fix: 🐛 fix request attributes for OIDC

This commit is contained in:
Randall Morey committed 2021-04-10 12:34:13 -04:00
1 parent 53423739d3
commit 5105d80a9d
4 files changed
+398 -378

No files matched your search

+3 -5
View File
@@ -63,7 +63,7 @@ const commandHandlers = {
* 1. `authenticate:start` kicks of authentication by requesting some details
* from the Boundary server about the request, including the third-party
* URL to which to redirect the user.
* 2. `authenticate` accepts the token_request_id and state parameters in
* 2. `authenticate` accepts the token_id and state parameters in
* order to retrieve a Boundary token. This endpoint may be polled until
* the authentication flow is completed.
*/
@@ -74,10 +74,8 @@ const commandHandlers = {
{},
{
attributes: {
authorization_request_url: 'https://www.duckduckgo.com',
retreival_url: '',
token_request_id: 'token_request_1234',
state: 'base_58_encoded_string',
auth_url: 'https://www.duckduckgo.com',
token_id: 'token_1234',
},
}
),
+6 -8
View File
@@ -10,8 +10,8 @@ import fetch from 'fetch';
* sub steps:
* 1. Initiate a call via `startAuthentication` to the API at
* `buildAuthEndpointURL` using the `start` command to fetch the URL of
* the external authentication provider (`authorization_request_url`).
* 2. Open `authorization_request_url`. This may be either inline (same tab)
* the external authentication provider (`auth_url`).
* 2. Open `auth_url`. This may be either inline (same tab)
* or external in a new tab or browser window.
* 2. Requests the token from `buildAuthEndpointURL` using the `token` command.
* A token isn't guaranteed to be ready, so the OIDC flow can be in a
@@ -84,21 +84,19 @@ export default class OIDCAuthenticator extends BaseAuthenticator {
const body = JSON.stringify({
command: 'token',
attributes: {
state: this.session.get('data.pending.oidc.state'),
token_request_id: this.session.get(
'data.pending.oidc.token_request_id'
),
//state: this.session.get('data.pending.oidc.attributes.state'),
token_id: this.session.get('data.pending.oidc.attributes.token_id'),
},
});
// Fetch the endpoint and get the response JSON
const response = await fetch(url, { method: 'post', body });
const json = await response.json();
if (response.status === 100) {
if (response.status === 204) {
// The token isn't ready yet, keep trying.
return false;
} else if (response.status < 400) {
// Response was successful, meaning a token was obtained.
// Authenticate with the session service using the response JSON.
const json = await response.json();
await this.session.authenticate('authenticator:oidc', json);
return true;
} else {
@@ -66,7 +66,7 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
// TODO: delegate this call from the session service so that we don't have
// to look up the authenticator directly
const json = await oidc.startAuthentication(options);
await this.openExternalOIDCFlow(json.attributes.authorization_request_url);
await this.openExternalOIDCFlow(json.attributes.auth_url);
}
/**
+388 -364
View File
File diff suppressed because it is too large. Load diff