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

Integrate Support for Short-Lived Tokens (STS) in Remote Authentication #7571

Merged
merged 15 commits into from
Mar 24, 2024

Conversation

guy-har
Copy link
Contributor

@guy-har guy-har commented Mar 18, 2024

This change Adds an authentication service and implements the STS authentication flow
Broke it into commits to make the review a bit easier (the first 5 commits).
The rest of the commits are changes to make the makefile build the generated files in the right time and the right place

@guy-har guy-har force-pushed the feature/token-by-sts branch 5 times, most recently from a239dc4 to 20dc236 Compare March 18, 2024 15:48
@guy-har guy-har force-pushed the feature/token-by-sts branch from 20dc236 to ba2fb1a Compare March 18, 2024 15:57
Copy link

github-actions bot commented Mar 18, 2024

♻️ PR Preview d46dbab has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

return nil, fmt.Errorf("claim %s has unexpected value %s: %w", claim, claimValue, ErrInvalidSTS)
}
}
subject, found := claims.Get("sub")
Copy link
Contributor

Choose a reason for hiding this comment

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

"sub" should be const

Copy link
Contributor

Choose a reason for hiding this comment

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

still relevant 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

why?

if !found {
return nil, fmt.Errorf("missing subject in claims: %w", ErrInvalidSTS)
}
expiresAt, found := claims.Get("exp")
Copy link
Contributor

Choose a reason for hiding this comment

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

"exp" should be const

Copy link
Contributor

Choose a reason for hiding this comment

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

This on too

name string
responseStatusCode int
expectedErr error
error error
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
error error
loginError error

Comment on lines +114 to 115
// initialize authorization service
var authService auth.Service
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 should rename also other places like the auth package name and authService variable for example
can be done in another PR

@guy-har guy-har force-pushed the feature/token-by-sts branch from af53e70 to 925d62f Compare March 20, 2024 09:23
@guy-har guy-har added the include-changelog PR description should be included in next release changelog label Mar 20, 2024
@guy-har guy-har changed the title Add STS login flow Integrate Support for Short-Lived Tokens (STS) in Remote Authentication Mar 20, 2024
@guy-har guy-har marked this pull request as ready for review March 20, 2024 09:46
@guy-har guy-har force-pushed the feature/token-by-sts branch 3 times, most recently from 55808d5 to d95bbcb Compare March 20, 2024 13:23
@guy-har guy-har force-pushed the feature/token-by-sts branch 2 times, most recently from 4ead615 to b008dca Compare March 20, 2024 14:13
@guy-har guy-har force-pushed the feature/token-by-sts branch 2 times, most recently from 4a1ecf5 to e4d2fb9 Compare March 20, 2024 14:49
Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

10 passed

@guy-har guy-har force-pushed the feature/token-by-sts branch from e4d2fb9 to 9c32b68 Compare March 20, 2024 15:06
Copy link
Contributor

@idanovo idanovo left a comment

Choose a reason for hiding this comment

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

Add few minor comments
Welcome to merge after answering/resolving 🙂

@@ -554,6 +556,24 @@ func (c *Controller) Login(w http.ResponseWriter, r *http.Request, body apigen.L
writeResponse(w, r, http.StatusOK, response)
}

func (c *Controller) STSLogin(w http.ResponseWriter, r *http.Request, body apigen.STSLoginJSONRequestBody) {
ctx := r.Context()
responseData, err := c.Authentication.ValidateSTS(ctx, body.Code, body.RedirectUri, body.State)
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 need to check here if external auth is enabled like we do with other calls

	if c.isExternalPrincipalNotSupported(ctx) {
		writeError(w, r, http.StatusNotImplemented, "Not implemented")
		return
	}

return nil, fmt.Errorf("claim %s has unexpected value %s: %w", claim, claimValue, ErrInvalidSTS)
}
}
subject, found := claims.Get("sub")
Copy link
Contributor

Choose a reason for hiding this comment

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

still relevant 🙂

if !found {
return nil, fmt.Errorf("missing subject in claims: %w", ErrInvalidSTS)
}
expiresAt, found := claims.Get("exp")
Copy link
Contributor

Choose a reason for hiding this comment

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

This on too

Comment on lines 4 to 5
description: fluffy HTTP API
title: fluffy API
Copy link
Contributor

Choose a reason for hiding this comment

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

You're fluffy, we're lakeFS 💪 !

@@ -177,12 +177,16 @@ type Config struct {
SecretKey SecureString `mapstructure:"secret_key" validate:"required"`
} `mapstructure:"encrypt"`
API struct {
// Endpoint is the endpoint to used for authorization operations
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Endpoint is the endpoint to used for authorization operations
// Endpoint for authorization operations

Endpoint string `mapstructure:"endpoint"`
Token SecureString `mapstructure:"token"`
SupportsInvites bool `mapstructure:"supports_invites"`
HealthCheckTimeout time.Duration `mapstructure:"health_check_timeout"`
SkipHealthCheck bool `mapstructure:"skip_health_check"`
} `mapstructure:"api"`
AuthenticationAPI struct {
Endpoint string `mapstructure:"endpoint"`
Copy link
Contributor

Choose a reason for hiding this comment

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

JUST AN IDEA:

Suggested change
Endpoint string `mapstructure:"endpoint"`
// Endpoint for authentication operations
Endpoint string `mapstructure:"endpoint"`

to make the difference clearer.

@@ -524,6 +528,9 @@ func (c *Config) IsAuthUISimplified() bool {
return c.Auth.UIConfig.RBAC == AuthRBACSimplified
}

func (c *Config) IsAuthenticationTypeAPI() bool {
return c.Auth.AuthenticationAPI.Endpoint != ""
}
func (c *Config) IsAuthTypeAPI() bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be changed to IsAuthorizationTypeAPI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't touch the Auth as part of this PR, given the fact that it may include some breaking changes such as configuration names

Copy link
Contributor

@Jonathan-Rosenberg Jonathan-Rosenberg left a comment

Choose a reason for hiding this comment

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

LGTM
Some minor comments, but the only blocking one is the authentication.yml one.
Thanks!!

@guy-har guy-har force-pushed the feature/token-by-sts branch from 328614f to d46dbab Compare March 24, 2024 08:07
Copy link
Contributor

@Jonathan-Rosenberg Jonathan-Rosenberg left a comment

Choose a reason for hiding this comment

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

Sababa

@guy-har guy-har merged commit 1babac4 into master Mar 24, 2024
37 checks passed
@guy-har guy-har deleted the feature/token-by-sts branch March 24, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include-changelog PR description should be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate Support for Short-Lived Tokens (STS) in Remote Authentication
3 participants