LogoutURL builds the RP-initiated logout URL if the provider supports it. Returns empty string if the provider has not yet been discovered or does not advertise an end_session_endpoint.
(postLogoutRedirectURI, idTokenHint, clientID string)
| 448 | // Returns empty string if the provider has not yet been discovered or does not |
| 449 | // advertise an end_session_endpoint. |
| 450 | func (c *Client) LogoutURL(postLogoutRedirectURI, idTokenHint, clientID string) string { |
| 451 | c.mu.Lock() |
| 452 | provider := c.provider |
| 453 | c.mu.Unlock() |
| 454 | if provider == nil { |
| 455 | return "" |
| 456 | } |
| 457 | var meta struct { |
| 458 | EndSessionEndpoint string `json:"end_session_endpoint"` |
| 459 | } |
| 460 | if err := provider.Claims(&meta); err != nil || meta.EndSessionEndpoint == "" { |
| 461 | return "" |
| 462 | } |
| 463 | |
| 464 | params := url.Values{} |
| 465 | params.Set("client_id", clientID) |
| 466 | params.Set("post_logout_redirect_uri", postLogoutRedirectURI) |
| 467 | if idTokenHint != "" { |
| 468 | params.Set("id_token_hint", idTokenHint) |
| 469 | } |
| 470 | return meta.EndSessionEndpoint + "?" + params.Encode() |
| 471 | } |