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

feat: Add config struct of OpenID-Connect Login #2597

Merged
merged 8 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/conf/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ authentication:
- username: user
password: user

oidc:
expire_time: 3600
app_name: authing
client_id:
client_secret:
scope: oidc
redirect_uri: oidc/callback

plugins: # plugin list (sorted in alphabetical order)
- api-breaker
- authz-keycloak
Expand Down
18 changes: 18 additions & 0 deletions api/internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var (
AccessLogPath = "logs/access.log"
UserList = make(map[string]User, 2)
AuthConf Authentication
OidcConf Oidc
SSLDefaultStatus = 1 //enable ssl by default
ImportSizeLimit = 10 * 1024 * 1024
AllowList []string
Expand Down Expand Up @@ -126,10 +127,20 @@ type Authentication struct {
Users []User
}

type Oidc struct {
ExpireTime int `mapstructure:"expire_time" yaml:"expire_time"`
AppName string `mapstructure:"app_name"`
ClientId string `mapstructure:"client_id"`
ClientSecret string `mapstructure:"client_secret"`
Scope string
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to add mapstructure of this field?

RedirectUri string `mapstructure:"redirect_uri"`
}

type Config struct {
Conf Conf
Authentication Authentication
Plugins []string
Oidc Oidc
}

type Security struct {
Expand Down Expand Up @@ -256,6 +267,9 @@ func setupConfig() {
// set authentication
initAuthentication(config.Authentication)

//set Oidc
initOidc(config.Oidc)

// set plugin
initPlugins(config.Plugins)

Expand Down Expand Up @@ -283,6 +297,10 @@ func initAuthentication(conf Authentication) {
}
}

func initOidc(conf Oidc) {
OidcConf = conf
}

func initPlugins(plugins []string) {
for _, pluginName := range plugins {
Plugins[pluginName] = true
Expand Down
5 changes: 1 addition & 4 deletions api/internal/filter/invalid_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@ func InvalidRequest() gin.HandlerFunc {
}

func checkURL(url *url.URL) bool {
if strings.Contains(url.Path, "..") {
return false
}
return true
return !strings.Contains(url.Path, "..")
}
3 changes: 1 addition & 2 deletions api/internal/handler/data_loader/loader/openapi3/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ func (o Loader) convertToEntities(s *openapi3.Swagger) (*loader.DataSets, error)

// create upstream when servers field not empty
if len(s.Servers) > 0 {
var upstream entity.Upstream
upstream = entity.Upstream{
upstream := entity.Upstream{
BaseInfo: entity.BaseInfo{ID: globalUpstreamID},
UpstreamDef: entity.UpstreamDef{
Name: globalUpstreamID,
Expand Down