@@ -59,26 +59,37 @@ func SetAuthRoutes(e *echo.Echo, cfgProvider *config.ConfigProviderWithRefresh)
59
59
60
60
providerCfg := serverCfg .Auth .Providers [0 ] // only single provider is currently supported
61
61
62
- if len (providerCfg .IssuerURL ) > 0 {
63
- ctx = oidc .InsecureIssuerURLContext (ctx , providerCfg .IssuerURL )
64
- }
65
- provider , err := oidc .NewProvider (ctx , providerCfg .ProviderURL )
66
- if err != nil {
67
- log .Fatal (err )
68
- }
62
+ api := e .Group ("/auth" )
63
+ switch providerCfg .Flow {
64
+ case "authorization-code" :
65
+ if len (providerCfg .IssuerURL ) > 0 {
66
+ ctx = oidc .InsecureIssuerURLContext (ctx , providerCfg .IssuerURL )
67
+ }
69
68
70
- oauthCfg := oauth2.Config {
71
- ClientID : providerCfg .ClientID ,
72
- ClientSecret : providerCfg .ClientSecret ,
73
- Endpoint : provider .Endpoint (),
74
- RedirectURL : providerCfg .CallbackURL ,
75
- Scopes : providerCfg .Scopes ,
76
- }
69
+ if len (providerCfg .AuthorizationURL ) > 0 {
70
+ log .Fatal (`authorization url should not be set for auth code flow` )
71
+ }
77
72
78
- api := e .Group ("/auth" )
79
- api .GET ("/sso" , authenticate (& oauthCfg , providerCfg .Options ))
80
- api .GET ("/sso/callback" , authenticateCb (ctx , & oauthCfg , provider ))
81
- api .GET ("/sso_callback" , authenticateCb (ctx , & oauthCfg , provider )) // compatibility with UI v1
73
+ provider , err := oidc .NewProvider (ctx , providerCfg .ProviderURL )
74
+ if err != nil {
75
+ log .Fatal (err )
76
+ }
77
+
78
+ oauthCfg := oauth2.Config {
79
+ ClientID : providerCfg .ClientID ,
80
+ ClientSecret : providerCfg .ClientSecret ,
81
+ Endpoint : provider .Endpoint (),
82
+ RedirectURL : providerCfg .CallbackURL ,
83
+ Scopes : providerCfg .Scopes ,
84
+ }
85
+
86
+ api .GET ("/sso" , authenticate (& oauthCfg , providerCfg .Options ))
87
+ api .GET ("/sso/callback" , authenticateCb (ctx , & oauthCfg , provider ))
88
+ api .GET ("/sso_callback" , authenticateCb (ctx , & oauthCfg , provider )) // compatibility with UI v1
89
+ case "implicit" :
90
+ // The implicit flow is principally designed for single-page applications.
91
+ // Fully delegated to the client.
92
+ }
82
93
}
83
94
84
95
func authenticate (config * oauth2.Config , options map [string ]interface {}) func (echo.Context ) error {
0 commit comments