-
Notifications
You must be signed in to change notification settings - Fork 545
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
feat: Add config struct of OpenID-Connect Login #2597
Changes from 6 commits
4d72b71
776a0eb
768d4b4
051b2fb
51a6a51
1ba6024
17908c2
caaf7c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,17 @@ authentication: | |
- username: user | ||
password: user | ||
|
||
oidc: | ||
secret: | ||
secret | ||
expire_time: 3600 | ||
apps: | ||
- app_name: authing | ||
client_id: | ||
client_secret: | ||
scope: oidc | ||
redirect_uri: /authing/callback | ||
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.
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. ok |
||
|
||
plugins: # plugin list (sorted in alphabetical order) | ||
- api-breaker | ||
- authz-keycloak | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,8 @@ var ( | |
AccessLogPath = "logs/access.log" | ||
UserList = make(map[string]User, 2) | ||
AuthConf Authentication | ||
AppList = make(map[string]App, 1) | ||
OidcConf Oidc | ||
SSLDefaultStatus = 1 //enable ssl by default | ||
ImportSizeLimit = 10 * 1024 * 1024 | ||
AllowList []string | ||
|
@@ -126,10 +128,25 @@ type Authentication struct { | |
Users []User | ||
} | ||
|
||
type App struct { | ||
AppName string `mapstructure:"app_name"` | ||
ClientId string `mapstructure:"client_id"` | ||
ClientSecret string `mapstructure:"client_secret"` | ||
Scope string | ||
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. Do we need to add |
||
RedirectUri string `mapstructure:"redirect_uri"` | ||
} | ||
|
||
type Oidc struct { | ||
Secret string | ||
ExpireTime int `mapstructure:"expire_time" yaml:"expire_time"` | ||
Apps []App | ||
} | ||
|
||
type Config struct { | ||
Conf Conf | ||
Authentication Authentication | ||
Plugins []string | ||
Oidc Oidc | ||
} | ||
|
||
type Security struct { | ||
|
@@ -256,6 +273,9 @@ func setupConfig() { | |
// set authentication | ||
initAuthentication(config.Authentication) | ||
|
||
//set Oidc | ||
initOidc(config.Oidc) | ||
|
||
// set plugin | ||
initPlugins(config.Plugins) | ||
|
||
|
@@ -283,6 +303,19 @@ func initAuthentication(conf Authentication) { | |
} | ||
} | ||
|
||
func initOidc(conf Oidc) { | ||
OidcConf = conf | ||
|
||
if OidcConf.Secret == "secret" { | ||
OidcConf.Secret = utils.GetFlakeUidStr() | ||
nic-chen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
appList := OidcConf.Apps | ||
|
||
for _, item := range appList { | ||
AppList[item.AppName] = item | ||
} | ||
} | ||
|
||
func initPlugins(plugins []string) { | ||
for _, pluginName := range plugins { | ||
Plugins[pluginName] = true | ||
|
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 can support one app first.
So just remove apps.
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.
ok