-
Notifications
You must be signed in to change notification settings - Fork 362
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
Conversation
a239dc4
to
20dc236
Compare
20dc236
to
ba2fb1a
Compare
♻️ 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") |
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.
"sub" should be const
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.
still relevant 🙂
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.
why?
if !found { | ||
return nil, fmt.Errorf("missing subject in claims: %w", ErrInvalidSTS) | ||
} | ||
expiresAt, found := claims.Get("exp") |
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.
"exp" should be const
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.
This on too
name string | ||
responseStatusCode int | ||
expectedErr error | ||
error error |
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.
error error | |
loginError error |
// initialize authorization service | ||
var authService auth.Service |
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 think we should rename also other places like the auth package name and authService variable for example
can be done in another PR
af53e70
to
925d62f
Compare
55808d5
to
d95bbcb
Compare
4ead615
to
b008dca
Compare
4a1ecf5
to
e4d2fb9
Compare
e4d2fb9
to
9c32b68
Compare
d54b233
to
902e15b
Compare
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.
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) |
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 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") |
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.
still relevant 🙂
if !found { | ||
return nil, fmt.Errorf("missing subject in claims: %w", ErrInvalidSTS) | ||
} | ||
expiresAt, found := claims.Get("exp") |
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.
This on too
api/authentication.yml
Outdated
description: fluffy HTTP API | ||
title: fluffy API |
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.
You're fluffy, we're lakeFS 💪 !
pkg/config/config.go
Outdated
@@ -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 |
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.
// 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"` |
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.
JUST AN IDEA:
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 { |
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.
should this be changed to IsAuthorizationTypeAPI
?
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.
Didn't touch the Auth as part of this PR, given the fact that it may include some breaking changes such as configuration names
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.
LGTM
Some minor comments, but the only blocking one is the authentication.yml
one.
Thanks!!
328614f
to
d46dbab
Compare
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.
Sababa
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