feat: 🎸 initial flow to open new window to 3rd party auth
This commit is contained in:
4 files changed
+117
-33
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import BaseAuthenticator from './base';
|
||||
// import { resolve, reject } from 'rsvp';
|
||||
// import fetch from 'fetch';
|
||||
//import { Promise } from 'rsvp';
|
||||
import { resolve, reject } from 'rsvp';
|
||||
import fetch from 'fetch';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -16,6 +15,43 @@ export default class OIDCAuthenticator extends BaseAuthenticator {
|
||||
authMethod: { id: authMethodID },
|
||||
} */) { }
|
||||
|
||||
buildStartAuthEndpointURL(/* {
|
||||
scope: { id: scopeID },
|
||||
authMethod: { id: authMethodID },
|
||||
} */) { }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async startAuthentication(
|
||||
creds,
|
||||
requestCookies = true,
|
||||
options
|
||||
) {
|
||||
const body = JSON.stringify({
|
||||
token_type: requestCookies ? 'cookie' : null
|
||||
});
|
||||
const authEndpointURL = this.buildStartAuthEndpointURL(options);
|
||||
const response = await fetch(authEndpointURL, { method: 'post', body });
|
||||
const json = await response.json();
|
||||
const normalized = this.normalizeData(json);
|
||||
if (response.status < 400) {
|
||||
await this.openExternalOIDCFlow(normalized.authorization_request_url);
|
||||
resolve(normalized);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the specified URL in a new tab or window. By default this uses
|
||||
* `window.open`, but may be overriden.
|
||||
* @param {string} url
|
||||
*/
|
||||
openExternalOIDCFlow(url) {
|
||||
window.open(url);
|
||||
}
|
||||
|
||||
async authenticate(
|
||||
// creds,
|
||||
// requestCookies = true,
|
||||
|
||||
Reference in new issue
Block a user