2022-10-19 23:26:25 +00:00
|
|
|
<StateChart @src={{this.chart}} as |State Guard ChartAction dispatch state|>
|
|
|
|
{{#let
|
|
|
|
(hash State=State Guard=Guard Action=ChartAction dispatch=dispatch state=state)
|
|
|
|
as |chart|
|
|
|
|
}}
|
|
|
|
{{#let
|
|
|
|
(hash
|
|
|
|
reset=(action dispatch 'RESET')
|
|
|
|
focus=this.focus
|
|
|
|
disabled=(state-matches state 'loading')
|
|
|
|
error=(queue
|
|
|
|
(action dispatch 'ERROR') (action (mut this.error) value='error.errors.firstObject')
|
2021-11-24 14:53:12 +00:00
|
|
|
)
|
2022-10-19 23:26:25 +00:00
|
|
|
submit=(queue (action (mut this.value)) (action dispatch 'SUBMIT'))
|
|
|
|
)
|
|
|
|
as |exported|
|
|
|
|
}}
|
|
|
|
<Guard @name='hasValue' @cond={{this.hasValue}} />
|
|
|
|
{{!TODO: Call this reset or similar }}
|
|
|
|
<chart.Action
|
|
|
|
@name='clearError'
|
|
|
|
@exec={{queue (action (mut this.error) undefined) (action (mut this.secret) undefined)}}
|
|
|
|
/>
|
|
|
|
<div class='auth-form' ...attributes>
|
|
|
|
<StateChart
|
|
|
|
@src={{this.tabsChart}}
|
|
|
|
as |TabState IgnoredGuard IgnoredAction tabDispatch tabState|
|
2021-11-24 14:53:12 +00:00
|
|
|
>
|
2022-10-19 23:26:25 +00:00
|
|
|
{{#if (can 'use SSO')}}
|
|
|
|
<TabNav
|
|
|
|
@items={{array
|
|
|
|
(hash label='Token' selected=(state-matches tabState 'token'))
|
|
|
|
(hash label='SSO' selected=(state-matches tabState 'sso'))
|
|
|
|
}}
|
|
|
|
@onclick={{queue (action tabDispatch) (action dispatch 'RESET')}}
|
|
|
|
/>
|
|
|
|
{{/if}}
|
|
|
|
<State @matches='error'>
|
|
|
|
{{#if this.error.status}}
|
|
|
|
<Notice @type='error' role='alert' as |notice|>
|
|
|
|
<notice.Body>
|
|
|
|
<p>
|
|
|
|
{{#if this.value.Name}}
|
|
|
|
{{#if (eq this.error.status '403')}}
|
|
|
|
<strong>Consul login failed</strong><br />
|
|
|
|
We received a token from your OIDC provider but could not log in to Consul
|
|
|
|
with it.
|
|
|
|
{{else if (eq this.error.status '401')}}
|
|
|
|
<strong>Could not log in to provider</strong><br />
|
|
|
|
The OIDC provider has rejected this access token. Please have an
|
|
|
|
administrator check your auth method configuration.
|
|
|
|
{{else if (eq this.error.status '499')}}
|
|
|
|
<strong>SSO log in window closed</strong><br />
|
|
|
|
The OIDC provider window was closed. Please try again.
|
|
|
|
{{else}}
|
|
|
|
<strong>Error</strong><br />
|
|
|
|
{{this.error.detail}}
|
|
|
|
{{/if}}
|
|
|
|
{{else}}
|
|
|
|
{{#if (eq this.error.status '403')}}
|
|
|
|
<strong>Invalid token</strong><br />
|
|
|
|
The token entered does not exist. Please enter a valid token to log in.
|
|
|
|
{{else if (eq this.error.status '404')}}
|
|
|
|
<strong>No providers</strong><br />
|
|
|
|
No SSO providers are configured for that Partition.
|
|
|
|
{{else}}
|
|
|
|
<strong>Error</strong><br />
|
|
|
|
{{this.error.detail}}
|
|
|
|
{{/if}}
|
|
|
|
{{/if}}
|
|
|
|
</p>
|
|
|
|
</notice.Body>
|
|
|
|
</Notice>
|
2020-05-11 15:37:11 +00:00
|
|
|
{{/if}}
|
|
|
|
</State>
|
2022-10-19 23:26:25 +00:00
|
|
|
<TabState @matches='token'>
|
|
|
|
<form onsubmit={{action dispatch 'SUBMIT'}}>
|
|
|
|
<fieldset>
|
|
|
|
<label
|
|
|
|
class={{concat
|
|
|
|
'type-password'
|
|
|
|
(if (and (state-matches state 'error') (not this.error.status)) ' has-error')
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<span>Log in with a token</span>
|
2021-11-24 14:53:12 +00:00
|
|
|
|
2022-10-19 23:26:25 +00:00
|
|
|
{{! Blink/Webkit based seem to leak password inputs }}
|
|
|
|
{{! this will only occur during acceptance testing so }}
|
|
|
|
{{! turn them into text inputs during acceptance testing }}
|
|
|
|
<input
|
|
|
|
{{did-insert (set this 'input')}}
|
|
|
|
disabled={{state-matches state 'loading'}}
|
|
|
|
type={{if (eq (env 'environment') 'testing') 'text' 'password'}}
|
|
|
|
name='auth[SecretID]'
|
|
|
|
placeholder='SecretID'
|
|
|
|
value={{this.secret}}
|
|
|
|
oninput={{queue
|
|
|
|
(action (mut this.secret) value='target.value')
|
|
|
|
(action (mut this.value) value='target.value')
|
|
|
|
(action dispatch 'TYPING')
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<State @matches='error'>
|
|
|
|
{{#if (not this.error.status)}}
|
|
|
|
<strong role='alert'>
|
|
|
|
Please enter your secret
|
|
|
|
</strong>
|
|
|
|
{{/if}}
|
|
|
|
</State>
|
|
|
|
</label>
|
|
|
|
</fieldset>
|
|
|
|
<Action @type='submit' disabled={{state-matches state 'loading'}}>
|
|
|
|
Log in
|
|
|
|
</Action>
|
|
|
|
</form>
|
|
|
|
</TabState>
|
2021-11-24 14:53:12 +00:00
|
|
|
|
2022-10-19 23:26:25 +00:00
|
|
|
{{yield (assign exported (hash Method=TabState))}}
|
2021-11-24 14:53:12 +00:00
|
|
|
|
2022-10-19 23:26:25 +00:00
|
|
|
<em>
|
|
|
|
Contact your administrator for login credentials.
|
|
|
|
</em>
|
|
|
|
</StateChart>
|
2021-11-24 14:53:12 +00:00
|
|
|
|
2022-10-19 23:26:25 +00:00
|
|
|
</div>
|
|
|
|
<State @matches='loading'>
|
|
|
|
<TokenSource
|
|
|
|
@dc={{@dc}}
|
|
|
|
@nspace={{or this.value.Namespace @nspace}}
|
|
|
|
@partition={{or this.value.Partition @partition}}
|
|
|
|
@type={{if this.value.Name 'oidc' 'secret'}}
|
|
|
|
@value={{this.value}}
|
|
|
|
@onchange={{queue (action dispatch 'RESET') @onsubmit}}
|
|
|
|
@onerror={{queue
|
|
|
|
(action (mut this.error) value='error.errors.firstObject')
|
|
|
|
(action dispatch 'ERROR')
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</State>
|
|
|
|
{{/let}}
|
|
|
|
{{/let}}
|
|
|
|
</StateChart>
|