Merge pull request #556 from hashicorp/feature-oidc-modeling

feat: 🎸 implement basic OIDC auth method attributes modeling
This commit is contained in:
Randall Morey authored and GitHub committed 2021-05-20 15:37:08 -04:00
commit 1f47ca8ea9
5 files changed
+71

No files matched your search

+22
View File
@@ -1,9 +1,31 @@
import GeneratedAuthMethodModel from '../generated/models/auth-method';
import { fragment } from 'ember-data-model-fragments/attributes';
import { equal } from '@ember/object/computed';
export const signingAlgorithms = [
'RS256',
'RS384',
'RS512',
'ES256',
'ES384',
'ES512',
'PS256',
'PS384',
'PS512',
'EdDSA',
];
export const states = ['inactive', 'active-private', 'active-public'];
export default class AuthMethodModel extends GeneratedAuthMethodModel {
// =attributes
/**
* Attributes of this resource, if any, represented as a JSON fragment.
* @type {FragmentAuthMethodAttributesModel}
*/
@fragment('fragment-auth-method-attributes', { defaultValue: {} }) attributes;
/**
* @type {boolean}
*/
@@ -0,0 +1,17 @@
import Fragment from 'ember-data-model-fragments/fragment';
import { attr } from '@ember-data/model';
export default class FragmentAuthMethodAttributesModel extends Fragment {
// =attributes (OIDC)
@attr('string', { readOnly: true }) state;
@attr('string') issuer;
@attr('string') client_id;
@attr('string') client_secret;
@attr('string') client_secret_hmac;
@attr('number') max_age;
@attr('string') api_url_prefix;
@attr('string') callback_url;
@attr('boolean') disable_discovered_config_validation;
@attr('boolean') dry_run;
}
@@ -0,0 +1 @@
export { default } from 'api/models/fragment-auth-method-attributes';
@@ -11,4 +11,22 @@ export default Factory.extend({
created_time: () => date.recent(),
updated_time: () => date.recent(),
disabled: () => datatype.boolean(),
attributes: function () {
let attrs;
switch (this.type) {
case 'oidc':
attrs = {
api_url_prefix: 'http://127.0.0.1:9200',
callback_url:
'http://127.0.0.1:9200/v1/auth-methods/oidc:authenticate:callback',
client_id: 'YTwdJBB55LpKnuXb9n65',
client_secret_hmac: 'GY7blb4ynM5TEPNi_qnphJ9aDWhW8FpmN3D-eP_L7Zk',
issuer: 'http://127.0.0.1:57070',
state: 'active-public',
};
break;
}
return attrs;
},
});
@@ -0,0 +1,13 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Model | fragment auth method attributes', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function (assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('fragment-auth-method-attributes', {});
assert.ok(model);
});
});