Skip to content

Conversation

@axbarsan
Copy link
Contributor

Part of the larger #1547

This PR adds the dex configuration, and CP Authentication redux logic

@axbarsan axbarsan added the kind/dev-change Changing a development operation label Aug 24, 2020
@axbarsan axbarsan self-assigned this Aug 24, 2020
import { CPAUTH_USER_EXPIRED, CPAUTH_USER_LOAD } from 'stores/cpauth/constants';
import { getCPAuthUser } from 'stores/cpauth/selectors';

export function cpAuthMiddleware(cpAuth: CPAuth): Middleware {
Copy link
Contributor Author

@axbarsan axbarsan Aug 24, 2020

Choose a reason for hiding this comment

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

This middleware is used to renew user information, if a user is expired.

In general, the user will be renewed automatically, but the flow will fail if there's a race condition between renewal and a separate request. This prevents that.
There is also the case where the token expires when the user while the user is not logged in, so automatic renew is not possible

This can also prevent actions from getting dispatched, if the user expired, if we want to use this auth method as a primary one.

import { defaultConfig } from 'lib/CPAuth/config';
import OAuth2 from 'lib/OAuth2/OAuth2';

class CPAuth extends OAuth2 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This inherits from the OAuth2 class, so we could have this as a singleton, but not limit the number of OAuth2 providers to a single one.

@axbarsan axbarsan requested a review from a team August 24, 2020 16:59
@axbarsan axbarsan marked this pull request as ready for review August 24, 2020 16:59
SignUp: '/signup/:token',
OAuthCallback: '/oauth/callback',
CPAccess: '/cp-access',
CPAccessCallback: '/cp-access/callback',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the path that the user is redirected to, after logging in

authority,
clientId: 'fFlz7lckhWA0kIaW3fLIl8chFSs2wvW6',
clientSecret:
'PoioOqWKUndxVnbcRzlv59EgvwPVJQIdIlved143Uko0SjGJ7OprnecZQbab3WhH',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we really gotta figure out a way to do this without a client secret...

We kinda need dex to support PKCE: dexidp/dex#1652

That's the flow we're using with auth0 I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great find with that PR!
But can we move forward with this PR until we get that sorted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Btw, I don't think this is a huge problem right now, as users still need to have access to the control plane they try to login on.

Take for example a customer installation. Try authenticating with the kubectl plugin. Dex will allow the authentication request, since the client ID and Secret are correct, but you won't actually be able to log in, since you're not registered in the customer's authentication configuration (e.g. active directory).

Copy link
Contributor

@oponder oponder left a comment

Choose a reason for hiding this comment

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

LGTM but not feeling 100% about the client secret, lets keep an eye on dex and improve that when the opportunity presents itself.

@axbarsan axbarsan merged commit 1aced0c into master Aug 26, 2020
@axbarsan axbarsan deleted the cp-auth/add-cp-redux-logic branch August 26, 2020 07:58
@HEllRZA
Copy link

HEllRZA commented Aug 26, 2020

Presenting Opportunity ;o)
dexidp/dex#1784

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/dev-change Changing a development operation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants