Skip to content

Commit

Permalink
feat: Add config struct of OpenID-Connect Login (#2597)
Browse files Browse the repository at this point in the history
Co-authored-by: wangglb <[email protected]>
Co-authored-by: Wang Zichen <[email protected]>
  • Loading branch information
3 people authored Aug 29, 2022
1 parent 0458664 commit 95566d5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
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
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

0 comments on commit 95566d5

Please sign in to comment.