feat: build the redirect after a successful login with AuthCallbackURL function
This commit is contained in:
parent
b914990e15
commit
c0908bf6fd
1 changed files with 13 additions and 1 deletions
14
pkg/op/op.go
14
pkg/op/op.go
|
@ -19,6 +19,7 @@ import (
|
||||||
const (
|
const (
|
||||||
healthEndpoint = "/healthz"
|
healthEndpoint = "/healthz"
|
||||||
readinessEndpoint = "/ready"
|
readinessEndpoint = "/ready"
|
||||||
|
authCallbackPathSuffix = "/callback"
|
||||||
defaultAuthorizationEndpoint = "authorize"
|
defaultAuthorizationEndpoint = "authorize"
|
||||||
defaultTokenEndpoint = "oauth/token"
|
defaultTokenEndpoint = "oauth/token"
|
||||||
defaultIntrospectEndpoint = "oauth/introspect"
|
defaultIntrospectEndpoint = "oauth/introspect"
|
||||||
|
@ -72,7 +73,7 @@ func CreateRouter(o OpenIDProvider, interceptors ...HttpInterceptor) *mux.Router
|
||||||
router.HandleFunc(readinessEndpoint, readyHandler(o.Probes()))
|
router.HandleFunc(readinessEndpoint, readyHandler(o.Probes()))
|
||||||
router.HandleFunc(oidc.DiscoveryEndpoint, discoveryHandler(o, o.Signer()))
|
router.HandleFunc(oidc.DiscoveryEndpoint, discoveryHandler(o, o.Signer()))
|
||||||
router.Handle(o.AuthorizationEndpoint().Relative(), intercept(authorizeHandler(o)))
|
router.Handle(o.AuthorizationEndpoint().Relative(), intercept(authorizeHandler(o)))
|
||||||
router.NewRoute().Path(o.AuthorizationEndpoint().Relative()+"/callback").Queries("id", "{id}").Handler(intercept(authorizeCallbackHandler(o)))
|
router.NewRoute().Path(authCallbackPath(o)).Queries("id", "{id}").Handler(intercept(authorizeCallbackHandler(o)))
|
||||||
router.Handle(o.TokenEndpoint().Relative(), intercept(tokenHandler(o)))
|
router.Handle(o.TokenEndpoint().Relative(), intercept(tokenHandler(o)))
|
||||||
router.HandleFunc(o.IntrospectionEndpoint().Relative(), introspectionHandler(o))
|
router.HandleFunc(o.IntrospectionEndpoint().Relative(), introspectionHandler(o))
|
||||||
router.HandleFunc(o.UserinfoEndpoint().Relative(), userinfoHandler(o))
|
router.HandleFunc(o.UserinfoEndpoint().Relative(), userinfoHandler(o))
|
||||||
|
@ -82,6 +83,17 @@ func CreateRouter(o OpenIDProvider, interceptors ...HttpInterceptor) *mux.Router
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//AuthCallbackURL builds the url for the redirect (with the requestID) after a successful login
|
||||||
|
func AuthCallbackURL(o OpenIDProvider) func(string) string {
|
||||||
|
return func(requestID string) string {
|
||||||
|
return o.AuthorizationEndpoint().Absolute(o.Issuer()) + authCallbackPathSuffix + "?id=" + requestID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func authCallbackPath(o OpenIDProvider) string {
|
||||||
|
return o.AuthorizationEndpoint().Relative() + authCallbackPathSuffix
|
||||||
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Issuer string
|
Issuer string
|
||||||
CryptoKey [32]byte
|
CryptoKey [32]byte
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue