2020-06-17 18:00:38 -04:00
|
|
|
import GeneratedAuthMethodModel from '../generated/models/auth-method';
|
2021-05-12 17:12:59 -04:00
|
|
|
import { fragment } from 'ember-data-model-fragments/attributes';
|
2021-03-24 18:36:34 -04:00
|
|
|
import { equal } from '@ember/object/computed';
|
2020-06-17 18:00:38 -04:00
|
|
|
|
2021-05-12 17:12:59 -04:00
|
|
|
export const signingAlgorithms = [
|
|
|
|
|
'RS256',
|
|
|
|
|
'RS384',
|
|
|
|
|
'RS512',
|
|
|
|
|
'ES256',
|
|
|
|
|
'ES384',
|
|
|
|
|
'ES512',
|
|
|
|
|
'PS256',
|
|
|
|
|
'PS384',
|
|
|
|
|
'PS512',
|
|
|
|
|
'EdDSA',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const states = ['inactive', 'active-private', 'active-public'];
|
|
|
|
|
|
2021-03-16 15:41:13 -04:00
|
|
|
export default class AuthMethodModel extends GeneratedAuthMethodModel {
|
|
|
|
|
// =attributes
|
|
|
|
|
|
2021-05-12 17:12:59 -04:00
|
|
|
/**
|
|
|
|
|
* Attributes of this resource, if any, represented as a JSON fragment.
|
|
|
|
|
* @type {FragmentAuthMethodAttributesModel}
|
|
|
|
|
*/
|
|
|
|
|
@fragment('fragment-auth-method-attributes', { defaultValue: {} }) attributes;
|
|
|
|
|
|
2021-03-26 12:47:49 -04:00
|
|
|
/**
|
|
|
|
|
* @type {boolean}
|
|
|
|
|
*/
|
2021-04-14 11:28:07 -04:00
|
|
|
@equal('is_primary', true) isPrimary;
|
2021-04-01 15:24:49 -04:00
|
|
|
|
2021-03-16 15:41:13 -04:00
|
|
|
/**
|
|
|
|
|
* @type {boolean}
|
|
|
|
|
*/
|
|
|
|
|
get isPassword() {
|
|
|
|
|
return this.type === 'password';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @type {boolean}
|
|
|
|
|
*/
|
|
|
|
|
get isOIDC() {
|
|
|
|
|
return this.type === 'oidc';
|
|
|
|
|
}
|
2021-05-13 14:10:37 -04:00
|
|
|
|
|
|
|
|
// =methods
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Change the active and visibility state of an OIDC auth method
|
|
|
|
|
* given its ID.
|
|
|
|
|
* For OIDC auth methods only.
|
|
|
|
|
* @param {[string]} state
|
|
|
|
|
* @param {object} options
|
|
|
|
|
* @param {object} options.adapterOptions
|
|
|
|
|
* @return {Promise}
|
|
|
|
|
*/
|
|
|
|
|
changeState(state, options = { adapterOptions: {} }) {
|
|
|
|
|
const defaultAdapterOptions = {
|
|
|
|
|
method: 'change-state',
|
|
|
|
|
state,
|
|
|
|
|
};
|
|
|
|
|
return this.save({
|
|
|
|
|
...options,
|
|
|
|
|
adapterOptions: {
|
|
|
|
|
...defaultAdapterOptions,
|
|
|
|
|
...options.adapterOptions,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-03-16 15:41:13 -04:00
|
|
|
}
|