mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-01 18:33:19 +02:00
core/authenticate: refactor idp sign out (#4589)
core/authenticate: refactor idp sign out (#4582) Co-authored-by: Caleb Doxsey <cdoxsey@pomerium.com>
This commit is contained in:
parent
57aead4eda
commit
e6ef8b68cc
16 changed files with 318 additions and 93 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