nagisa-kunhah commented on code in PR #1542:
URL: https://github.com/apache/dubbo-admin/pull/1542#discussion_r3927513511
##########
pkg/config/console/auth/config.go:
##########
@@ -19,26 +19,136 @@ package auth
import (
"errors"
+ "fmt"
+ "net/url"
+ "regexp"
+ "slices"
"github.com/apache/dubbo-admin/pkg/config"
)
-const DefaultExpirationTime = 7200
+const (
+ DefaultExpirationTime = 7200
+ DefaultSessionSecret = "secret"
+
+ MethodPassword = "password"
+ ProviderTypeGitHub = "github"
+ ProviderTypeOIDC = "oidc"
+)
+
+var providerIDPattern = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$`)
+
+type ProviderConfig struct {
+ Type string `json:"type" yaml:"type"`
+ DisplayName string `json:"displayName" yaml:"displayName"`
+ Issuer string `json:"issuer,omitempty"
yaml:"issuer,omitempty"`
+ ClientID string `json:"clientId" yaml:"clientId"`
+ ClientSecret string `json:"clientSecret" yaml:"clientSecret"`
+ RedirectURL string `json:"redirectUrl" yaml:"redirectUrl"`
+ PostLoginRedirectURL string `json:"postLoginRedirectUrl"
yaml:"postLoginRedirectUrl"`
+ Scopes []string `json:"scopes,omitempty"
yaml:"scopes,omitempty"`
+}
// Config AuthConfig configure the valid user and password
type Config struct {
config.BaseConfig
- User string `json:"user"`
- Password string `json:"password"`
- ExpirationTime int `json:"expirationTime"`
+ Methods []string `json:"methods"
yaml:"methods"`
+ User string `json:"user" yaml:"user"`
+ Password string `json:"password"
yaml:"password"`
+ ExpirationTime int `json:"expirationTime"
yaml:"expirationTime"`
+ SessionSecret string `json:"sessionSecret"
yaml:"sessionSecret"`
+ SessionCookieSecure bool
`json:"sessionCookieSecure" yaml:"sessionCookieSecure"`
+ Providers map[string]ProviderConfig
`json:"providers,omitempty" yaml:"providers,omitempty"`
+}
+
+func (c *Config) Sanitize() {
+ c.Password = config.SanitizedValue
+ c.SessionSecret = config.SanitizedValue
+ for id, provider := range c.Providers {
+ provider.ClientSecret = config.SanitizedValue
+ c.Providers[id] = provider
+ }
}
func (c *Config) Validate() error {
- if c.User == "" || c.Password == "" {
+ if len(c.Methods) == 0 {
+ c.Methods = []string{MethodPassword}
+ }
Review Comment:
Password login is now enabled by default only when methods is omitted (nil).
An explicitly configured empty list remains empty, allowing provider-only
deployments to disable the password login endpoint.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]