chore: manual merge from main
This commit is contained in:
14 files changed
+102
-79
No files matched your search
@@ -1,10 +1,7 @@
|
||||
import factory from '../generated/factories/auth-method';
|
||||
import { trait } from 'ember-cli-mirage';
|
||||
|
||||
const types = [
|
||||
'password',
|
||||
'oidc'
|
||||
];
|
||||
const types = ['password', 'oidc'];
|
||||
|
||||
export default factory.extend({
|
||||
id: (i) => `auth-method-id-${i}`,
|
||||
|
||||
@@ -35,20 +35,24 @@ const methodHandlers = {
|
||||
if (payload.credentials.login_name === 'error') {
|
||||
return new Response(400);
|
||||
} else {
|
||||
return new Response(200, {}, {
|
||||
scope: scopeAttrs,
|
||||
id: 'token123',
|
||||
token: 'thetokenstring',
|
||||
account_id: '1',
|
||||
user_id: 'user123',
|
||||
auth_method_id: 'authmethod123',
|
||||
created_time: '',
|
||||
updated_time: '',
|
||||
last_used_time: '',
|
||||
expiration_time: ''
|
||||
});
|
||||
return new Response(
|
||||
200,
|
||||
{},
|
||||
{
|
||||
scope: scopeAttrs,
|
||||
id: 'token123',
|
||||
token: 'thetokenstring',
|
||||
account_id: '1',
|
||||
user_id: 'user123',
|
||||
auth_method_id: 'authmethod123',
|
||||
created_time: '',
|
||||
updated_time: '',
|
||||
last_used_time: '',
|
||||
expiration_time: '',
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -63,37 +67,47 @@ const methodHandlers = {
|
||||
*/
|
||||
oidc: {
|
||||
'authenticate:start': () =>
|
||||
new Response(200, {}, {
|
||||
authorization_request_url: 'https://www.duckduckgo.com',
|
||||
retreival_url: '',
|
||||
token_request_id: 'token_request_1234',
|
||||
state: 'base_58_encoded_string'
|
||||
}),
|
||||
new Response(
|
||||
200,
|
||||
{},
|
||||
{
|
||||
authorization_request_url: 'https://www.duckduckgo.com',
|
||||
retreival_url: '',
|
||||
token_request_id: 'token_request_1234',
|
||||
state: 'base_58_encoded_string',
|
||||
}
|
||||
),
|
||||
'authenticate:token': (_, scopeAttrs) => {
|
||||
oidcAttemptCounter++;
|
||||
if (oidcAttemptCounter < oidcRequiredAttempts) {
|
||||
return new Response(100);
|
||||
} else {
|
||||
return new Response(200, {}, {
|
||||
scope: scopeAttrs,
|
||||
id: 'token123',
|
||||
token: 'thetokenstring',
|
||||
account_id: '1',
|
||||
user_id: 'user123',
|
||||
auth_method_id: 'authmethod123',
|
||||
created_time: '',
|
||||
updated_time: '',
|
||||
last_used_time: '',
|
||||
expiration_time: ''
|
||||
});
|
||||
return new Response(
|
||||
200,
|
||||
{},
|
||||
{
|
||||
scope: scopeAttrs,
|
||||
id: 'token123',
|
||||
token: 'thetokenstring',
|
||||
account_id: '1',
|
||||
user_id: 'user123',
|
||||
auth_method_id: 'authmethod123',
|
||||
created_time: '',
|
||||
updated_time: '',
|
||||
last_used_time: '',
|
||||
expiration_time: '',
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export function authHandler({ scopes, authMethods }, request) {
|
||||
const payload = JSON.parse(request.requestBody);
|
||||
const [, id, method] = request.params.id_method.match(/(?<id>.[^:]*)(?::)?(?<method>.*)?/);
|
||||
const [, id, method] = request.params.id_method.match(
|
||||
/(?<id>.[^:]*)(?::)?(?<method>.*)?/
|
||||
);
|
||||
const authMethod = authMethods.find(id);
|
||||
const scope = scopes.find(authMethod.scopeId);
|
||||
const scopeAttrs = this.serialize(scopes.find(scope.id));
|
||||
|
||||
@@ -22,7 +22,6 @@ import fetch from 'fetch';
|
||||
* `authenticators/application.js` and extend this class.
|
||||
*/
|
||||
export default class OIDCAuthenticator extends BaseAuthenticator {
|
||||
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
@@ -40,7 +39,7 @@ export default class OIDCAuthenticator extends BaseAuthenticator {
|
||||
buildStartAuthEndpointURL(/* {
|
||||
scope: { id: scopeID },
|
||||
authMethod: { id: authMethodID },
|
||||
} */) { }
|
||||
} */) {}
|
||||
|
||||
/**
|
||||
* Generates an auth method URL with which to authenticate.
|
||||
@@ -53,7 +52,7 @@ export default class OIDCAuthenticator extends BaseAuthenticator {
|
||||
buildTokenAuthEndpointURL(/* {
|
||||
scope: { id: scopeID },
|
||||
authMethod: { id: authMethodID },
|
||||
} */) { }
|
||||
} */) {}
|
||||
|
||||
/**
|
||||
* Kicks-off the OIDC flow: calls the `authenticate:start` action on the
|
||||
@@ -72,7 +71,7 @@ export default class OIDCAuthenticator extends BaseAuthenticator {
|
||||
if (response.status < 400) {
|
||||
// Store meta about the pending OIDC flow
|
||||
this.session.set('data.pending', {
|
||||
oidc: json
|
||||
oidc: json,
|
||||
});
|
||||
return json;
|
||||
} else {
|
||||
@@ -108,7 +107,7 @@ export default class OIDCAuthenticator extends BaseAuthenticator {
|
||||
const url = this.buildTokenAuthEndpointURL(options);
|
||||
const body = JSON.stringify({
|
||||
state: this.session.get('data.pending.oidc.state'),
|
||||
token_request_id: this.session.get('data.pending.oidc.token_request_id')
|
||||
token_request_id: this.session.get('data.pending.oidc.token_request_id'),
|
||||
});
|
||||
// Fetch the endpoint and get the response JSON
|
||||
const response = await fetch(url, { method: 'post', body });
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { module/*, test */} from 'qunit';
|
||||
import { module /*, test */ } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import { inject as service } from '@ember/service';
|
||||
* An OIDC authenticator that handles flow kick-off and polling.
|
||||
*/
|
||||
export default class OIDCAuthenticator extends BaseOIDCAuthenticator {
|
||||
|
||||
// =services
|
||||
|
||||
@service store;
|
||||
@@ -28,8 +27,8 @@ export default class OIDCAuthenticator extends BaseOIDCAuthenticator {
|
||||
const options = {
|
||||
adapterOptions: {
|
||||
scopeID,
|
||||
method: 'authenticate:start'
|
||||
}
|
||||
method: 'authenticate:start',
|
||||
},
|
||||
};
|
||||
return adapter.buildURL('auth-method', authMethodID, options, 'findRecord');
|
||||
}
|
||||
@@ -49,7 +48,9 @@ export default class OIDCAuthenticator extends BaseOIDCAuthenticator {
|
||||
authMethod: { id: authMethodID },
|
||||
}) {
|
||||
const adapter = this.store.adapterFor('application');
|
||||
const options = { adapterOptions: { scopeID, method: 'authenticate:token' } };
|
||||
const options = {
|
||||
adapterOptions: { scopeID, method: 'authenticate:token' },
|
||||
};
|
||||
return adapter.buildURL('auth-method', authMethodID, options, 'findRecord');
|
||||
}
|
||||
|
||||
@@ -63,5 +64,4 @@ export default class OIDCAuthenticator extends BaseOIDCAuthenticator {
|
||||
const adapter = this.store.adapterFor('auth-token');
|
||||
return adapter.buildURL('auth-token', tokenID, {}, 'findRecord');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
export { default } from 'core/components/form/authenticate/oidc';
|
||||
export { default } from 'core/components/form/authenticate/oidc';
|
||||
@@ -10,7 +10,7 @@ Router.map(function () {
|
||||
this.route('scopes', function () {
|
||||
this.route('scope', { path: ':scope_id' }, function () {
|
||||
this.route('authenticate', function () {
|
||||
this.route('method', { path: ':auth_method_id' }, function() {
|
||||
this.route('method', { path: ':auth_method_id' }, function () {
|
||||
this.route('oidc');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,10 +49,10 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
|
||||
this.transitionTo('index');
|
||||
break;
|
||||
case 'oidc':
|
||||
await this.startOIDCAuthentication(
|
||||
authenticatorName,
|
||||
{ scope, authMethod }
|
||||
);
|
||||
await this.startOIDCAuthentication(authenticatorName, {
|
||||
scope,
|
||||
authMethod,
|
||||
});
|
||||
this.transitionTo('scopes.scope.authenticate.method.oidc');
|
||||
break;
|
||||
}
|
||||
@@ -78,5 +78,4 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
|
||||
// TODO don't use window directly
|
||||
await window.open(url);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeAuthenticateMethodIndexRoute extends Route {
|
||||
}
|
||||
export default class ScopesScopeAuthenticateMethodIndexRoute extends Route {}
|
||||
@@ -29,6 +29,7 @@ export default class ScopesScopeAuthenticateMethodOidcRoute extends Route {
|
||||
yield timeout(POLL_TIMEOUT_SECONDS * 1000);
|
||||
yield this.refresh();
|
||||
}
|
||||
/* eslint-disable-next-line prettier/prettier */
|
||||
}).drop() poller;
|
||||
|
||||
// =methods
|
||||
|
||||
@@ -66,11 +66,11 @@ module('Acceptance | authentication', function (hooks) {
|
||||
scope = { id: orgScope.id, type: orgScope.type };
|
||||
globalAuthMethod = this.server.create('auth-method', {
|
||||
scope: globalScope,
|
||||
type: 'password'
|
||||
type: 'password',
|
||||
});
|
||||
authMethod = this.server.create('auth-method', {
|
||||
scope: orgScope,
|
||||
type: 'password'
|
||||
type: 'password',
|
||||
});
|
||||
orgScopeID = orgScope.id;
|
||||
globalAuthMethodID = globalAuthMethod.id;
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/authenticate/method/index', function(hooks) {
|
||||
setupTest(hooks);
|
||||
module(
|
||||
'Unit | Route | scopes/scope/authenticate/method/index',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/authenticate/method/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup(
|
||||
'route:scopes/scope/authenticate/method/index'
|
||||
);
|
||||
assert.ok(route);
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -1,11 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/authenticate/method/oidc', function(hooks) {
|
||||
setupTest(hooks);
|
||||
module(
|
||||
'Unit | Route | scopes/scope/authenticate/method/oidc',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/authenticate/method/oidc');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup(
|
||||
'route:scopes/scope/authenticate/method/oidc'
|
||||
);
|
||||
assert.ok(route);
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -57,7 +57,8 @@ app.on('ready', async () => {
|
||||
// Register custom protocol
|
||||
// This file protocol is the exclusive protocol for this application. All
|
||||
// other protocols are disabled.
|
||||
ses.protocol.registerFileProtocol(emberAppProtocol, (request, callback) => { /* eng-disable PROTOCOL_HANDLER_JS_CHECK */
|
||||
ses.protocol.registerFileProtocol(emberAppProtocol, (request, callback) => {
|
||||
/* eng-disable PROTOCOL_HANDLER_JS_CHECK */
|
||||
const isDir = request.url.endsWith('/');
|
||||
const absolutePath = request.url.substr(emberAppURL.length);
|
||||
const normalizedPath = isDir
|
||||
@@ -71,7 +72,8 @@ app.on('ready', async () => {
|
||||
|
||||
// Disallow all permissions requests,
|
||||
// per Electronegativity PERMISSION_REQUEST_HANDLER_GLOBAL_CHECK
|
||||
ses.setPermissionRequestHandler((webContents, permission, callback) => { /* eng-disable PERMISSION_REQUEST_HANDLER_JS_CHECK */
|
||||
ses.setPermissionRequestHandler((webContents, permission, callback) => {
|
||||
/* eng-disable PERMISSION_REQUEST_HANDLER_JS_CHECK */
|
||||
return callback(false);
|
||||
});
|
||||
|
||||
@@ -119,7 +121,7 @@ app.on('ready', async () => {
|
||||
allowRunningInsecureContent: false,
|
||||
// The preload script establishes the message-based IPC pathway without
|
||||
// exposing new modules to the renderer.
|
||||
preload: preloadPath, /* eng-disable PRELOAD_JS_CHECK */
|
||||
preload: preloadPath /* eng-disable PRELOAD_JS_CHECK */,
|
||||
disableBlinkFeatures: 'Auxclick',
|
||||
},
|
||||
});
|
||||
@@ -151,10 +153,12 @@ app.on('ready', async () => {
|
||||
|
||||
// Prevent navigation outside of serve://boundary per
|
||||
// Electronegativity LIMIT_NAVIGATION_GLOBAL_CHECK
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => { /* eng-disable LIMIT_NAVIGATION_JS_CHECK */
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
/* eng-disable LIMIT_NAVIGATION_JS_CHECK */
|
||||
if (!url.startsWith('serve://boundary')) event.preventDefault();
|
||||
});
|
||||
mainWindow.webContents.on('new-window', (event, url) => { /* eng-disable LIMIT_NAVIGATION_JS_CHECK */
|
||||
mainWindow.webContents.on('new-window', (event, url) => {
|
||||
/* eng-disable LIMIT_NAVIGATION_JS_CHECK */
|
||||
if (!url.startsWith('serve://boundary')) event.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user