-
Notifications
You must be signed in to change notification settings - Fork 63
[Breaking] OAuth2 Authorization Server implementation, Separate OpenID and OAuth2 configs, OAuth2 Metadata over gRPC #minor #168
Conversation
pkg/auth/oauthserver/initialize.go
Outdated
handler.HandleFunc(jsonWebKeysUrl.String(), GetJSONWebKeysEndpoint(authCtx)) | ||
} else { | ||
// The metadata endpoint is an RFC-defined constant, but we need a leading / for the handler to pattern match correctly. | ||
handler.HandleFunc(fmt.Sprintf("/%s", auth.OAuth2MetadataEndpoint), GetMetadataRedirect(authCtx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else can be eliminated and L30 can be removed from the if block.
pkg/auth/config/config.go
Outdated
}, | ||
"flytepropeller": { | ||
ID: "flytepropeller", | ||
Secret: []byte(`$2a$10$IxMdI6d.LIRZPpSfEwNoeu4rY3FhDREsxFJXikcgdRRAStxUlsuEO`), // = "foobar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming this would be fed in to the app through a secrets engine and not be in the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to flytepropeller for example? yes, I'm going to add it to the sandbox deployment so that flytepropeller has it already deployed... and then in the guide we should tell people how to change it...
pkg/auth/oauthserver/metadata.go
Outdated
"code token", | ||
}, | ||
GrantTypesSupported: supportedGrantTypes, | ||
ScopesSupported: []string{auth.ScopeAll}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs offline scope for refresh token to work
There is one refresh token issue which we spoke about where the expiry is incorrect.
Other than that i see my changes working from flytectl. |
@EngHabu something seems off here, this is a huge PR, Does every open source product have to implement this? Should this be a separate service? |
One question here: If we have a none flyteconsole web app which wants to access flyteadmin, does it require still require a cookie in the header, or we can pass the id/access token in |
It can pass access tokens it acquires through OAuth2 2 or 3 legged
flows....
On Mon, Apr 19, 2021 at 4:37 AM tnsetting ***@***.***> wrote:
One question here: If we have a none flyteconsole web app which wants to
access flyteadmin, does it require still require a cookie in the header, or
we can pass the id/access token in authorization from web app directly
which is similar to the grpc one?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#168 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAGUF4SCHSXWFIRUPXMK23TJQIX7ANCNFSM4ZYKG5RA>
.
--
Thanks,
Haytham Abuelfutuh.
|
@EngHabu Thanks for your reply. I just check a bit about the ID token and access token. In our case we want to use the ID token since the ID token contains user information and we need this information. The other issue with the google access token is that google access token only has two parts and does not comply with JWT token format. |
@EngHabu Also we want to try this PR out, but is it possible to provide a sample configuration for GCP so we can try it as the config section for auth has been changed a lot? Thanks. |
@tnsetting, please checkout the new docs here With an example for Google IdP |
} | ||
|
||
func getJwksForIssuer(ctx context.Context, issuerBaseURL url.URL) (oidc.KeySet, error) { | ||
u, err := url.Parse(auth.OAuth2MetadataEndpoint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of using google as the idp, the link https://accounts.google.com/.well-known/oauth-authorization-server does not exist so the getJwksForIssuer
is failing when configured the baseUrl
as https://accounts.google.com
. Can we fall back to use OIdCMetadataEndpoint
when this is failing? So this link does exist https://accounts.google.com/.well-known/openid-configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google can't be used as the external OAuth2 Authorization Server... their server only protects other Google Endpoints. You can setup/use GCP Identity Platform instead (I do not have instructions for how to do that)...
If you follow the guide here, it takes you through setting up Google Idp just for OpenID Connect while continuing to use FlyteAdmin's own certs to act as the OAuth2 Authorization Server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually need to use Google as authentication server because of gcloud service accounts. What want to do for authentication is just to verify who is actually who
based on ID token. Regarding authorisation, when we know what the user it is we can fetch custom roles from google (it is possible to add custom role) and implement a very thin layer of access control. In this way we don't need have a separate service to store access policies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what the guide takes you through... setting up OpenID Connect with Google IdP... have you tried that?
Let's chat over slack (@haytham) and I would be happy to help you debug and get it up and running
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I managed to get it running but it required me to make some code changes (hack). I will create a PR for these changes.
return nil, fmt.Errorf("expected exactly one granted audience. found [%v]", len(claims.Audience)) | ||
} | ||
|
||
if claims.Audience[0] != expectedAudience { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if claims.Audience[0] != expectedAudience { | |
if !strings.Contains(expectedAudience, claims.Audience[0]) { |
It looks the code will always prepend http/https
to the url but in our case the audience[0]
does not have that prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you use as an Authorization Server? Okta? KeyCloak? if so, you can configure them to issue tokens with a specific audience...
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Prafulla Mahindrakar <prafulla.mahindrakar@gmail.com> Co-authored-by: Prafulla Mahindrakar <prafulla.mahindrakar@gmail.com> Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
* wip: added version pkg Signed-off-by: yuvraj <evalsocket@gmail.com> * wip: resolve conflict Signed-off-by: yuvraj <evalsocket@gmail.com> * wip: added version in rpc Signed-off-by: yuvraj <evalsocket@gmail.com> * wip: small fixes Signed-off-by: yuvraj <evalsocket@gmail.com> * wip: Added panic cache in get version service Signed-off-by: yuvraj <evalsocket@gmail.com> * Added flytestdlib for version package Signed-off-by: yuvraj <evalsocket@gmail.com> * Added version service test Signed-off-by: yuvraj <evalsocket@gmail.com> * wip: added ldflags in goreleaser Signed-off-by: yuvraj <evalsocket@gmail.com> Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Codecov Report
@@ Coverage Diff @@
## master #168 +/- ##
==========================================
- Coverage 63.93% 61.79% -2.15%
==========================================
Files 105 120 +15
Lines 7353 8087 +734
==========================================
+ Hits 4701 4997 +296
- Misses 2072 2463 +391
- Partials 580 627 +47
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
…D and OAuth2 configs, OAuth2 Metadata over gRPC #minor (#168) * wip: OAuth2 Support Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * wip Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * wip Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * tighten security of generated tokens Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Support storing form post values in auth code JWT Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * save secrets to k8s secrets Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Expose metadata endpoints over gRPC Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * trim OpenID Connect config further Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Selectively authenticate gRPC endpoints Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Support external oauth2 server and Okta Config Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * update config Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Fix nil secrets data map Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Fixed the pointer overwrite issue in oauthServer metadata (#183) Signed-off-by: Prafulla Mahindrakar <prafulla.mahindrakar@gmail.com> Co-authored-by: Prafulla Mahindrakar <prafulla.mahindrakar@gmail.com> Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Unit tests Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Unit tests Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Simplify config further and move auth package up Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Fix clusterresource Project and domain(#167) * Fix clusterresource Project Signed-off-by: Anand Swaminathan <aswaminathan@lyft.com> Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Bump flyteidl version to pick up auth role field number fix (#169) Signed-off-by: Katrina Rogan <katroganGH@gmail.com> Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Add option to use project name as namespace for the task pods (#166) * Add option to use project name as namespace for the task pods Signed-off-by: Jeev B <jeev.balakrishnan@freenome.com> * rename Signed-off-by: Jeev B <jeev.balakrishnan@freenome.com> Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * GetExecution performance improvements (#171) Signed-off-by: Katrina Rogan <katroganGH@gmail.com> Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Add exists check for workflow & node executions (#172) Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Remove legacy fetch for workflow execution inputs (#173) Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Added release workflow (#170) Signed-off-by: yuvraj <evalsocket@gmail.com> Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Update Flyteidl version (#175) Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Added version in flyteadmin (#154) * wip: added version pkg Signed-off-by: yuvraj <evalsocket@gmail.com> * wip: resolve conflict Signed-off-by: yuvraj <evalsocket@gmail.com> * wip: added version in rpc Signed-off-by: yuvraj <evalsocket@gmail.com> * wip: small fixes Signed-off-by: yuvraj <evalsocket@gmail.com> * wip: Added panic cache in get version service Signed-off-by: yuvraj <evalsocket@gmail.com> * Added flytestdlib for version package Signed-off-by: yuvraj <evalsocket@gmail.com> * Added version service test Signed-off-by: yuvraj <evalsocket@gmail.com> * wip: added ldflags in goreleaser Signed-off-by: yuvraj <evalsocket@gmail.com> Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Propagate nesting and principal for child executions (#177) Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Write workflow and node execution events asynchronously (#174) Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Add sensible flyteadmin config defaults (#179) Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Lint Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * further cleanup Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Only register authserver when auth is enabled Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Update to latest flyteidl and separate auth interfaces Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * dead code Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * PR Comments Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * merge master Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Move to authorizedUris Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Update to released flyteidl Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Fix response expiry and add unit tests Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * Update go mod Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> * fix unit tests that broke because of identity changes Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com> Co-authored-by: pmahindrakar-oss <77798312+pmahindrakar-oss@users.noreply.github.com> Co-authored-by: Prafulla Mahindrakar <prafulla.mahindrakar@gmail.com> Co-authored-by: Anand Swaminathan <aswaminathan@lyft.com> Co-authored-by: Katrina Rogan <katrina@nuclyde.io> Co-authored-by: Jeev B <jeevb@users.noreply.github.com> Co-authored-by: Yuvraj <10830562+evalsocket@users.noreply.github.com> Co-authored-by: Flyte Bot <admin@flyte.org>
Signed-off-by: Haytham Abuelfutuh haytham@afutuh.com
TL;DR
This PR completes the implementation of OAuth2 and OpenID Connected started in Admin. The notable changes are:
Type
Are all requirements met?
Tracking Issue
flyteorg/flyte#925