Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Improved Login/Logout flow inc SSO support #7790

Merged
merged 19 commits into from
May 11, 2020
Merged

Conversation

johncowen
Copy link
Contributor

@johncowen johncowen commented May 6, 2020

This PR contains the remaining work involved in the improved login/logout flow:

  1. Consul can present different data in any 'view' depending on whether you provide an ACL token or not (i.e. you are logged in or not), therefore Login/Logout is now available/is easily accessible in the UI permanently in the top right of the main navigation bar on all pages/views.
  2. Logging/out works the same way as if we had been able to use cookies to achieve this, i.e. you log in/out in one tab and it logs you in/out in all your tabs. As with Cookies, using an incognito tab/window lets you log in with 2 different ACLs if required.
  3. SSO support for multiple OIDC providers when SSO support is enabled the Consul version.
  4. When using SSO, logging out will delete the ACL token that was created as part of the OIDC login flow.

The test amends here are only to move our existing testing to use the new flow.

Further work (probably in further PRs):

  1. Add more tests.
  2. It would be nice to remember the users preferred SSO provider so it is the top option the next time they return.
  3. Change the path for the Consul UI redirect url. Done.
  4. Possibly a few other little nips and tucks.

I've split this work up into specific separate 'category' commits thinking it might help with review if folks wanted to just look at each 'category' in isolation (see commits)

Development Cookies required to test this whilst in development and/or staging:

  • CONSUL_ACLS_ENABLE = 1: This is required to enable the login/logout functionality, without this you don't see any new things.
  • CONSUL_SSO_ENABLE = 1: Enable the SSO functionality.
  • CONSUL_OIDC_PROVIDER_COUNT = 5: Control the amount of OIDC providers that are returned from the API.
  • CONSUL_OIDC_PROVIDER_URL=http://somewhere/authorize?clientid=my-id&etc: Provide your own real OIDC provider authorization URL in order to play/test without a real Consul.
  • CONSUL_NSPACES_ENABLE = 1 : Enable Namespaces support in order to test token namespace redirection.

Currently you have to provide your own OIDC provider authorization URL in order to test this. There is work coming that provides a fake provider so that providing your own becomes an optional extra rather than a requirements.

Screengrabs:

Screenshot 2020-05-06 at 12 28 19

Screenshot 2020-05-06 at 12 29 05

@johncowen johncowen added the theme/ui Anything related to the UI label May 6, 2020
@johncowen johncowen requested a review from a team May 6, 2020 10:13
@johncowen johncowen added this to the 1.8.0 milestone May 6, 2020
@johncowen
Copy link
Contributor Author

Ah tests will break now with that last push, awaiting this to be merged:

hashicorp/consul-api-double#12

(oops sorry I forgot I was waiting on that, and pushed the CSS work 😬 )

Copy link
Contributor

@kaxcode kaxcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@johncowen johncowen force-pushed the ui/feature/sso branch 4 times, most recently from 70f5759 to 3060488 Compare May 7, 2020 18:25
John Cowen added 19 commits May 11, 2020 15:09
UI Components:

1. AuthDialog: Wraps/orchestrates AuthForm and AuthProfile
2. AuthForm: Authorization form shown when logged out.
3. AuthProfile: Simple presentational component to show the users
'Profile'
4. OidcSelect: A 'select' component for selecting an OIDC provider,
dynamically uses either a single select menu or multiple buttons
depending on the amount of providers

Data Components:

1. JwtSource: Given an OIDC provider URL this component will request a
token from the provider and fire an donchange event when it has been
retrieved. Used by TokenSource.
2. TokenSource: Given a oidc provider name or a Consul SecretID,
TokenSource will use whichever method/API requests required to retrieve
Consul ACL Token, which is emitted to the onchange event handler.

Very basic README documentation included here, which is likely to be
refined somewhat.
..plus extremely basics/skipped rendering tests for the new components
Previously we've always treated what the user typed as the truth, this
breaks down when using SSO as the user doesn't type anything to retrieve
a token. Therefore we change this so that we use the secret in the API
response as the truth.
Move everything that gets exported to the top level component itself
@johncowen johncowen merged commit 1d01a73 into ui-staging May 11, 2020
@johncowen johncowen deleted the ui/feature/sso branch May 11, 2020 15:37
kaxcode pushed a commit that referenced this pull request May 11, 2020
* 6 new components for new login/logout flow, plus SSO support

UI Components:

1. AuthDialog: Wraps/orchestrates AuthForm and AuthProfile
2. AuthForm: Authorization form shown when logged out.
3. AuthProfile: Simple presentational component to show the users
'Profile'
4. OidcSelect: A 'select' component for selecting an OIDC provider,
dynamically uses either a single select menu or multiple buttons
depending on the amount of providers

Data Components:

1. JwtSource: Given an OIDC provider URL this component will request a
token from the provider and fire an donchange event when it has been
retrieved. Used by TokenSource.
2. TokenSource: Given a oidc provider name or a Consul SecretID,
TokenSource will use whichever method/API requests required to retrieve
Consul ACL Token, which is emitted to the onchange event handler.

Very basic README documentation included here, which is likely to be
refined somewhat.

* CSS required for new auth/SSO UI components

* Remaining app code required to tie the new auth/SSO work together

* CSS code required to help tie the auth/SSO work together

* Test code in order to get current tests passing with new auth/SSO flow

..plus extremely basics/skipped rendering tests for the new components

* Treat the secret received from the server as the truth

Previously we've always treated what the user typed as the truth, this
breaks down when using SSO as the user doesn't type anything to retrieve
a token. Therefore we change this so that we use the secret in the API
response as the truth.

* Make sure removing an dom tree from a buffer only removes its own tree
johncowen added a commit that referenced this pull request May 12, 2020
* 6 new components for new login/logout flow, plus SSO support

UI Components:

1. AuthDialog: Wraps/orchestrates AuthForm and AuthProfile
2. AuthForm: Authorization form shown when logged out.
3. AuthProfile: Simple presentational component to show the users
'Profile'
4. OidcSelect: A 'select' component for selecting an OIDC provider,
dynamically uses either a single select menu or multiple buttons
depending on the amount of providers

Data Components:

1. JwtSource: Given an OIDC provider URL this component will request a
token from the provider and fire an donchange event when it has been
retrieved. Used by TokenSource.
2. TokenSource: Given a oidc provider name or a Consul SecretID,
TokenSource will use whichever method/API requests required to retrieve
Consul ACL Token, which is emitted to the onchange event handler.

Very basic README documentation included here, which is likely to be
refined somewhat.

* CSS required for new auth/SSO UI components

* Remaining app code required to tie the new auth/SSO work together

* CSS code required to help tie the auth/SSO work together

* Test code in order to get current tests passing with new auth/SSO flow

..plus extremely basics/skipped rendering tests for the new components

* Treat the secret received from the server as the truth

Previously we've always treated what the user typed as the truth, this
breaks down when using SSO as the user doesn't type anything to retrieve
a token. Therefore we change this so that we use the secret in the API
response as the truth.

* Make sure removing an dom tree from a buffer only removes its own tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants