mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 02:16:28 +02:00
* core/authenticate: refactor identity authenticators to initiate redirect, use cookie for redirect url for cognito * set secure and http only, update test
28 lines
797 B
Go
28 lines
797 B
Go
package httputil
|
|
|
|
import "net/http"
|
|
|
|
const signedOutRedirectURICookieName = "_pomerium_signed_out_redirect_uri"
|
|
|
|
// GetSignedOutRedirectURICookie gets the redirect uri cookie for the signed-out page.
|
|
func GetSignedOutRedirectURICookie(w http.ResponseWriter, r *http.Request) (string, bool) {
|
|
cookie, err := r.Cookie(signedOutRedirectURICookieName)
|
|
if err != nil {
|
|
return "", false
|
|
}
|
|
|
|
cookie.MaxAge = -1
|
|
http.SetCookie(w, cookie)
|
|
return cookie.Value, true
|
|
}
|
|
|
|
// SetSignedOutRedirectURICookie sets the redirect uri cookie for the signed-out page.
|
|
func SetSignedOutRedirectURICookie(w http.ResponseWriter, redirectURI string) {
|
|
http.SetCookie(w, &http.Cookie{
|
|
Name: signedOutRedirectURICookieName,
|
|
Value: redirectURI,
|
|
MaxAge: 5 * 60,
|
|
HttpOnly: true,
|
|
Secure: true,
|
|
})
|
|
}
|