-
Notifications
You must be signed in to change notification settings - Fork 135
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
Refactor auth feature flag #1089
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
fd7dd71
refactor(*): feature flag
shhdgit 8bd2e44
chore: refine feature flag
shhdgit 74a0937
refine: feature flag middleware
shhdgit 178a377
Merge branch 'master' into refactor/feature-flag
shhdgit f6ec213
refactor: move version utils to util package
shhdgit beafba3
chore: make lint happy
shhdgit 0b4dd21
Merge branch 'master' into refactor/feature-flag
shhdgit 4857960
refine(feature): flag & manager
shhdgit 8c9c89c
test(feature_flag): add manager tests
shhdgit 28a97f3
refine(util): feature flag
shhdgit a9382e9
*: update feature flag
shhdgit 1a39419
Merge branch 'master' into refactor/feature-flag
shhdgit 43b297d
*: update feature flag
shhdgit cc55adc
chore: make lint happy
shhdgit 15490d5
chore: revert lint
shhdgit 3401a7f
Update index.tsx
shhdgit c7e50e0
Update Detail.tsx
shhdgit c4e1a03
refine: feature flag
shhdgit 94e5e95
fix: fx & indirect x/tools version
shhdgit 90d09a6
refactor: authenticator register & feature flag
shhdgit 5d723a2
Merge branch 'master' into refactor/user
shhdgit 7b96335
Merge branch 'master' into refactor/user
shhdgit aa78a25
test(util): update feature flag ut
shhdgit 4c90ad6
chore: update user feature flag name
shhdgit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0. | ||
|
||
package shared | ||
|
||
import "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" | ||
|
||
type AuthenticatorRegister interface { | ||
Register(typeID utils.AuthType, a Authenticator) | ||
} | ||
|
||
type AuthenticateForm struct { | ||
Type utils.AuthType `json:"type" example:"0"` | ||
Username string `json:"username" example:"root"` // Does not present for AuthTypeSharingCode | ||
Password string `json:"password"` | ||
Extra string `json:"extra"` // FIXME: Use strong type | ||
} | ||
|
||
type SignOutInfo struct { | ||
EndSessionURL string `json:"end_session_url"` | ||
} | ||
|
||
type Authenticator interface { | ||
IsEnabled() (bool, error) | ||
Authenticate(form AuthenticateForm) (*utils.SessionUser, error) | ||
ProcessSession(u *utils.SessionUser) bool | ||
SignOutInfo(u *utils.SessionUser, redirectURL string) (*SignOutInfo, error) | ||
} | ||
|
||
type BaseAuthenticator struct{} | ||
|
||
func (a BaseAuthenticator) IsEnabled() (bool, error) { | ||
return true, nil | ||
} | ||
|
||
func (a BaseAuthenticator) ProcessSession(u *utils.SessionUser) bool { | ||
return true | ||
} | ||
|
||
func (a BaseAuthenticator) SignOutInfo(u *utils.SessionUser, redirectURL string) (*SignOutInfo, error) { | ||
return &SignOutInfo{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0. | ||
|
||
package shared | ||
|
||
import "github.com/joomcode/errorx" | ||
|
||
var ( | ||
ErrNS = errorx.NewNamespace("error.api.user") | ||
ErrUnsupportedAuthType = ErrNS.NewType("unsupported_auth_type") | ||
ErrUnsupportedUser = ErrNS.NewType("unsupported_user") | ||
ErrNSSignIn = ErrNS.NewSubNamespace("signin") | ||
ErrSignInOther = ErrNSSignIn.NewType("other") | ||
ErrInsufficientPrivs = ErrNSSignIn.NewType("insufficient_priv") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0. | ||
|
||
package shared | ||
|
||
import "github.com/pingcap/tidb-dashboard/util/featureflag" | ||
|
||
type UserFeatureFlags struct { | ||
NonRootLogin *featureflag.FeatureFlag | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is something shared. It is SQL sign-in specific thing. I would rather see SSO to rely on something of SQL sign-in, instead of introducing SQL sign-in for all authenticators via |
||
} | ||
|
||
func ProvideFeatureFlags(featureFlags *featureflag.Registry) *UserFeatureFlags { | ||
return &UserFeatureFlags{ | ||
NonRootLogin: featureFlags.Register("nonRootLogin", ">= 5.3.0"), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
pkg/apiserver/user/verify_sql_user_test.go → ...erver/user/shared/verify_sql_user_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0. | ||
|
||
package user | ||
package shared | ||
|
||
import ( | ||
"testing" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is SQL sign-in specific and should not be put in
shared