consul/ui/packages/consul-ui/app/components/token-source/index.hbs

61 lines
1.5 KiB
Handlebars

<StateChart
@src={{this.chart}}
@initial={{if (eq @type 'oidc') 'provider' 'secret'}}
as |State Guard Action dispatch state|>
<Guard
@name="isSecret"
@cond={{this.isSecret}}
/>
{{#let
(uri '/${partition}/{$nspace}/${dc}'
(hash
partition=@partition
nspace=@nspace
dc=@dc
)
)
as |path|}}
<State @matches="secret">
<DataSource
@src={{uri (concat path '/token/self/${value}')
(hash
value=@value
)
}}
@onchange={{this.change}}
@onerror={{@onerror}}
/>
</State>
<State @matches="provider">
<DataSource
@src={{uri (concat path '/oidc/provider/${value}')
(hash
value=@value
)
}}
@onchange={{queue (action (mut this.provider) value="data") (action dispatch "SUCCESS")}}
@onerror={{@onerror}}
/>
</State>
<State @matches="jwt">
<JwtSource
@src={{this.provider.AuthURL}}
@onchange={{queue (action (mut this.jwt) value="data") (action dispatch "SUCCESS")}}
@onerror={{@onerror}}
/>
</State>
<State @matches="token">
<DataSource
@src={{uri (concat path '/oidc/authorize/${provider}/${code}/${state}')
(hash
provider=this.provider.Name
code=this.jwt.authorizationCode
state=(or this.jwt.authorizationState '')
)
}}
@onchange={{this.change}}
@onerror={{@onerror}}
/>
</State>
{{/let}}
</StateChart>