mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 08:50:42 +02:00
core/authenticate: refactor idp sign out
This commit is contained in:
parent
9088f07cc9
commit
f649d9b1bc
11 changed files with 245 additions and 79 deletions
|
@ -6,10 +6,12 @@ package auth0
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/identity/oauth"
|
||||
pom_oidc "github.com/pomerium/pomerium/internal/identity/oidc"
|
||||
"github.com/pomerium/pomerium/internal/urlutil"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -47,3 +49,28 @@ func New(ctx context.Context, o *oauth.Options) (*Provider, error) {
|
|||
func (p *Provider) Name() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
// GetSignOutURL implements logout as described in https://auth0.com/docs/api/authentication#logout.
|
||||
func (p *Provider) GetSignOutURL(_, redirectToURL string) (string, error) {
|
||||
oa, err := p.GetOauthConfig()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error getting auth0 oauth config: %w", err)
|
||||
}
|
||||
|
||||
authURL, err := urlutil.ParseAndValidateURL(oa.Endpoint.AuthURL)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error parsing auth0 endpoint auth url: %w", err)
|
||||
}
|
||||
|
||||
logoutQuery := url.Values{
|
||||
"client_id": {oa.ClientID},
|
||||
}
|
||||
if redirectToURL != "" {
|
||||
logoutQuery.Set("returnTo", redirectToURL)
|
||||
}
|
||||
logoutURL := authURL.ResolveReference(&url.URL{
|
||||
Path: "/v2/logout",
|
||||
RawQuery: logoutQuery.Encode(),
|
||||
})
|
||||
return logoutURL.String(), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue