@@ -59,26 +59,37 @@ func SetAuthRoutes(e *echo.Echo, cfgProvider *config.ConfigProviderWithRefresh)
5959
6060	providerCfg  :=  serverCfg .Auth .Providers [0 ] // only single provider is currently supported 
6161
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+ 		}
6968
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+ 		}
7772
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+ 	}
8293}
8394
8495func  authenticate (config  * oauth2.Config , options  map [string ]interface {}) func (echo.Context ) error  {
0 commit comments