2018-09-25 16:28:26 +00:00
import { computed } from '@ember/object' ;
2018-07-24 22:35:31 +00:00
import DS from 'ember-data' ;
import AuthConfig from '../auth-config' ;
import fieldToAttrs from 'vault/utils/field-to-attrs' ;
2019-03-14 21:01:56 +00:00
import { combineFieldGroups } from 'vault/utils/openapi-to-attrs' ;
2018-07-24 22:35:31 +00:00
const { attr } = DS ;
export default AuthConfig . extend ( {
2019-03-14 21:01:56 +00:00
useOpenAPI : true ,
2018-07-24 22:35:31 +00:00
oidcDiscoveryUrl : attr ( 'string' , {
label : 'OIDC discovery URL' ,
helpText :
'The OIDC discovery URL, without any .well-known component (base path). Cannot be used with jwt_validation_pubkeys' ,
} ) ,
2019-03-14 21:01:56 +00:00
oidcClientId : attr ( 'string' , {
label : 'OIDC client ID' ,
} ) ,
oidcClientSecret : attr ( 'string' , {
label : 'OIDC client secret' ,
} ) ,
2018-07-24 22:35:31 +00:00
oidcDiscoveryCaPem : attr ( 'string' , {
label : 'OIDC discovery CA PEM' ,
editType : 'file' ,
helpText :
'The CA certificate or chain of certificates, in PEM format, to use to validate connections to the OIDC Discovery URL. If not set, system certificates are used' ,
} ) ,
jwtValidationPubkeys : attr ( {
label : 'JWT validation public keys' ,
editType : 'stringArray' ,
} ) ,
2019-03-14 21:01:56 +00:00
jwtSupportedAlgs : attr ( {
label : 'JWT supported algorithms' ,
} ) ,
2018-07-24 22:35:31 +00:00
boundIssuer : attr ( 'string' , {
helpText : 'The value against which to match the iss claim in a JWT' ,
} ) ,
fieldGroups : computed ( function ( ) {
2019-03-14 21:01:56 +00:00
let type = this . constructor . modelName . split ( '/' ) [ 1 ] . toUpperCase ( ) ;
let groups = [
2018-07-24 22:35:31 +00:00
{
2019-03-14 21:01:56 +00:00
default : [ 'oidcDiscoveryUrl' , 'defaultRole' ] ,
2018-07-24 22:35:31 +00:00
} ,
{
2019-03-14 21:01:56 +00:00
[ ` ${ type } Options ` ] : [
'oidcClientId' ,
'oidcClientSecret' ,
'oidcDiscoveryCaPem' ,
'jwtValidationPubkeys' ,
'jwtSupportedAlgs' ,
'boundIssuer' ,
] ,
2018-07-24 22:35:31 +00:00
} ,
] ;
2019-03-14 21:01:56 +00:00
if ( this . newFields ) {
groups = combineFieldGroups ( groups , this . newFields , [ ] ) ;
}
2018-07-24 22:35:31 +00:00
return fieldToAttrs ( this , groups ) ;
} ) ,
} ) ;