2020-05-11 15:37:11 +00:00
|
|
|
<StateChart @src={{chart}} as |State Guard Action dispatch state|>
|
|
|
|
{{yield (hash
|
|
|
|
reset=(action dispatch "RESET")
|
|
|
|
focus=(action 'focus')
|
|
|
|
)}}
|
|
|
|
<Guard @name="hasValue" @cond={{action 'hasValue'}} />
|
2021-10-01 10:07:58 +00:00
|
|
|
{{!TODO: Call this reset or similar }}
|
2020-05-11 15:37:11 +00:00
|
|
|
<Action @name="clearError" @exec={{queue (action (mut error) undefined) (action (mut secret) undefined)}} />
|
|
|
|
<div class="auth-form" ...attributes>
|
|
|
|
<State @matches="error">
|
|
|
|
{{#if error.status}}
|
2020-10-26 16:51:53 +00:00
|
|
|
<Notice
|
|
|
|
@type="error"
|
|
|
|
role="alert"
|
|
|
|
as |notice|>
|
|
|
|
<notice.Body>
|
|
|
|
<p>
|
|
|
|
{{#if value.Name}}
|
|
|
|
{{#if (eq 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 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 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 />
|
|
|
|
{{error.detail}}
|
|
|
|
{{/if}}
|
|
|
|
{{else}}
|
|
|
|
{{#if (eq error.status '403')}}
|
|
|
|
<strong>Invalid token</strong><br />
|
|
|
|
The token entered does not exist. Please enter a valid token to log in.
|
|
|
|
{{else}}
|
|
|
|
<strong>Error</strong><br />
|
|
|
|
{{error.detail}}
|
|
|
|
{{/if}}
|
|
|
|
{{/if}}
|
|
|
|
</p>
|
|
|
|
</notice.Body>
|
|
|
|
</Notice>
|
2020-05-11 15:37:11 +00:00
|
|
|
{{/if}}
|
|
|
|
</State>
|
|
|
|
<form onsubmit={{action dispatch "SUBMIT"}}>
|
|
|
|
<fieldset>
|
|
|
|
<label class={{concat "type-password" (if (and (state-matches state 'error') (not error.status)) ' has-error' '')}}>
|
|
|
|
<span>Log in with a token</span>
|
|
|
|
<input
|
|
|
|
{{ref this 'input'}}
|
|
|
|
disabled={{state-matches state "loading"}}
|
2020-05-20 13:09:09 +00:00
|
|
|
type={{inputType}}
|
2020-05-11 15:37:11 +00:00
|
|
|
name="auth[SecretID]"
|
|
|
|
placeholder="SecretID"
|
|
|
|
value={{secret}}
|
|
|
|
oninput={{queue
|
|
|
|
(action (mut secret) value="target.value")
|
|
|
|
(action (mut value) value="target.value")
|
|
|
|
(action dispatch "TYPING")
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<State @matches="error">
|
|
|
|
{{#if (not error.status)}}
|
|
|
|
<strong role="alert">
|
|
|
|
Please enter your secret
|
|
|
|
</strong>
|
|
|
|
{{/if}}
|
|
|
|
</State>
|
|
|
|
</label>
|
|
|
|
</fieldset>
|
|
|
|
<button type="submit" disabled={{state-matches state "loading"}}>
|
|
|
|
Log in
|
|
|
|
</button>
|
|
|
|
<em>Contact your administrator for login credentials.</em>
|
|
|
|
</form>
|
|
|
|
{{#if (env 'CONSUL_SSO_ENABLED')}}
|
ui: Don't default to the default namespace, use the token default namespace instead (#10503)
The default namespace, and the tokens default namespace (or its origin namespace) is slightly more complicated than other things we deal with in the UI, there's plenty of info/docs on this that I've added in this PR.
Previously:
When a namespace was not specified in the URL, we used to default to the default namespace. When you logged in using a token we automatically forward you the namespace URL that your token originates from, so you are then using the namespace for your token by default. You can of course then edit the URL to remove the namespace portion, or perhaps revisit the UI at the root path with you token already set. In these latter cases we would show you information from the default namespace. So if you had no namespace segment/portion in the URL, we would assume default, perform actions against the default namespace and highlight the default namespace in the namespace selector menu. If you wanted to perform actions in your tokens origin namespace you would have to manually select it from the namespace selector menu.
This PR:
Now, when you have no namespace segment/portion in the URL, we use the token's origin namespace instead (and if you don't have a token, we then use the default namespace like it was previously)
Notes/thoughts:
I originally thought we were showing an incorrectly selected namespace in the namespace selector, but it also matched up with what we were doing with the API, so it was in fact correct. The issue was more that we weren't selecting the origin namespace of the token for the user when a namespace segment was omitted from the URL. Seeing as we automatically forward you to the tokens origin namespace when you log in, and we were correctly showing the namespace we were acting on when you had no namespace segment in the URL (in the previous case default), I'm not entirely sure how much of an issue this actually was.
This characteristic of namespace+token+namespace is a little weird and its easy to miss a subtlety or two so I tried to add some documentation in here for future me/someone else (including some in depth code comment around one of the API endpoints where this is very subtle and very hard to miss). I'm not the greatest at words, so would be great to get some edits there if it doesn't seem clear to folks.
The fact that we used to save your previous datacenter and namespace into local storage for reasons also meant the interaction here was slightly more complicated than it needed to be, so whilst we were here we rejigged things slightly to satisfy said reasons still but not use local storage (we try and grab the info from higher up). A lot of the related code here is from before we had our Routlets which I think could probably make all of this a lot less complicated, but I didn't want to do a wholesale replacement in this PR, we can save that for a separate PR on its own at some point.
2021-07-07 10:46:41 +00:00
|
|
|
{{!-- This `or` can be completely removed post 1.10 as 1.10 has optional params with default values --}}
|
2020-05-11 15:37:11 +00:00
|
|
|
<DataSource
|
2021-09-15 18:50:11 +00:00
|
|
|
@src={{uri '/${partition}/${nspace}/${dc}/oidc/providers'
|
|
|
|
(hash
|
|
|
|
partition=partition
|
|
|
|
nspace=(or nspace '')
|
|
|
|
dc=dc
|
|
|
|
)
|
|
|
|
}}
|
2020-05-11 15:37:11 +00:00
|
|
|
@onchange={{queue (action (mut providers) value="data")}}
|
|
|
|
@onerror={{queue (action (mut error) value="error.errors.firstObject")}}
|
|
|
|
@loading="lazy"
|
|
|
|
/>
|
|
|
|
{{#if (gt providers.length 0)}}
|
|
|
|
<p>
|
|
|
|
<span>or</span>
|
|
|
|
</p>
|
|
|
|
{{/if}}
|
|
|
|
<OidcSelect
|
|
|
|
@items={{providers}}
|
|
|
|
@disabled={{state-matches state "loading"}}
|
|
|
|
@onchange={{queue (action (mut value)) (action dispatch "SUBMIT") }}
|
|
|
|
@onerror={{queue (action (mut error) value="error.errors.firstObject") (action dispatch "ERROR")}}
|
|
|
|
/>
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
<State @matches="loading">
|
2021-09-15 18:50:11 +00:00
|
|
|
{{!FIXME: default partition?}}
|
2020-05-11 15:37:11 +00:00
|
|
|
<TokenSource
|
|
|
|
@dc={{dc}}
|
2020-05-12 11:51:49 +00:00
|
|
|
@nspace={{or value.Namespace nspace}}
|
2021-09-15 18:50:11 +00:00
|
|
|
@partition={{or value.Partition 'default'}}
|
2020-05-11 15:37:11 +00:00
|
|
|
@type={{if value.Name 'oidc' 'secret'}}
|
|
|
|
@value={{if value.Name value.Name value}}
|
2020-05-27 10:23:21 +00:00
|
|
|
@onchange={{queue (action dispatch "RESET") (action onsubmit)}}
|
2020-05-11 15:37:11 +00:00
|
|
|
@onerror={{queue (action (mut error) value="error.errors.firstObject") (action dispatch "ERROR")}}
|
|
|
|
/>
|
|
|
|
</State>
|
|
|
|
</StateChart>
|