mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-04 04:46:01 +02:00
authenticate: fix callback handler for split mode (#4010)
authenticate: fix callback handler for split mode (#4008) fix auth handler for split mode Co-authored-by: Denis Mishin <dmishin@pomerium.com>
This commit is contained in:
parent
7f6797ba74
commit
baf36965bd
1 changed files with 26 additions and 9 deletions
|
@ -74,21 +74,38 @@ func (b *Builder) buildPomeriumHTTPRoutes(options *config.Options, host string)
|
||||||
routes = append(routes, b.buildControlPlanePathRoute("/robots.txt", false))
|
routes = append(routes, b.buildControlPlanePathRoute("/robots.txt", false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if we're handling authentication, add the oauth2 callback url
|
|
||||||
// as the callback url is from the IdP, it is expected only on the public authenticate URL endpoint
|
authRoutes, err := b.buildPomeriumAuthenticateHTTPRoutes(options, host)
|
||||||
authenticateURL, err := options.GetAuthenticateURL()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if config.IsAuthenticate(options.Services) && urlMatchesHost(authenticateURL, host) {
|
routes = append(routes, authRoutes...)
|
||||||
routes = append(routes,
|
|
||||||
b.buildControlPlanePathRoute(options.AuthenticateCallbackPath, false),
|
|
||||||
b.buildControlPlanePathRoute("/", false),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return routes, nil
|
return routes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Builder) buildPomeriumAuthenticateHTTPRoutes(options *config.Options, host string) ([]*envoy_config_route_v3.Route, error) {
|
||||||
|
if !config.IsAuthenticate(options.Services) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, fn := range []func() (*url.URL, error){
|
||||||
|
options.GetAuthenticateURL,
|
||||||
|
options.GetInternalAuthenticateURL,
|
||||||
|
} {
|
||||||
|
u, err := fn()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if urlMatchesHost(u, host) {
|
||||||
|
return []*envoy_config_route_v3.Route{
|
||||||
|
b.buildControlPlanePathRoute(options.AuthenticateCallbackPath, false),
|
||||||
|
b.buildControlPlanePathRoute("/", false),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Builder) buildControlPlanePathRoute(path string, protected bool) *envoy_config_route_v3.Route {
|
func (b *Builder) buildControlPlanePathRoute(path string, protected bool) *envoy_config_route_v3.Route {
|
||||||
r := &envoy_config_route_v3.Route{
|
r := &envoy_config_route_v3.Route{
|
||||||
Name: "pomerium-path-" + path,
|
Name: "pomerium-path-" + path,
|
||||||
|
|
Loading…
Add table
Reference in a new issue