Documentation ¶
Index ¶
- Variables
- type CookieRequestTracker
- func (t CookieRequestTracker) GetTrackedRequest(r *http.Request, index string) (*TrackedRequest, error)
- func (t CookieRequestTracker) GetTrackedRequests(r *http.Request) []TrackedRequest
- func (t CookieRequestTracker) StopTrackingRequest(w http.ResponseWriter, r *http.Request, index string) error
- func (t CookieRequestTracker) TrackRequest(w http.ResponseWriter, r *http.Request, samlRequestID string) (string, error)
- type JWTTrackedRequestClaims
- type JWTTrackedRequestCodec
- type RequestTracker
- type TrackedRequest
- type TrackedRequestCodec
Constants ¶
This section is empty.
Variables ¶
var DefaultJWTSigningMethod = jwt.SigningMethodRS256
Functions ¶
This section is empty.
Types ¶
type CookieRequestTracker ¶
type CookieRequestTracker struct { ServiceProvider *provider.ServiceProvider NamePrefix string Codec TrackedRequestCodec MaxAge time.Duration RelayStateFunc func(w http.ResponseWriter, r *http.Request) string SameSite http.SameSite }
CookieRequestTracker tracks requests by setting a uniquely named cookie for each request.
func (CookieRequestTracker) GetTrackedRequest ¶
func (t CookieRequestTracker) GetTrackedRequest(r *http.Request, index string) (*TrackedRequest, error)
GetTrackedRequest returns a pending tracked request.
func (CookieRequestTracker) GetTrackedRequests ¶
func (t CookieRequestTracker) GetTrackedRequests(r *http.Request) []TrackedRequest
GetTrackedRequests returns all the pending tracked requests
func (CookieRequestTracker) StopTrackingRequest ¶
func (t CookieRequestTracker) StopTrackingRequest(w http.ResponseWriter, r *http.Request, index string) error
StopTrackingRequest stops tracking the SAML request given by index, which is a string previously returned from TrackRequest
func (CookieRequestTracker) TrackRequest ¶
func (t CookieRequestTracker) TrackRequest(w http.ResponseWriter, r *http.Request, samlRequestID string) (string, error)
TrackRequest starts tracking the SAML request with the given ID. It returns an `index` that should be used as the RelayState in the SAMl request flow.
type JWTTrackedRequestClaims ¶
type JWTTrackedRequestClaims struct { jwt.RegisteredClaims TrackedRequest SAMLAuthnRequest bool `json:"saml-authn-request"` }
JWTTrackedRequestClaims represents the JWT claims for a tracked request.
type JWTTrackedRequestCodec ¶
type JWTTrackedRequestCodec struct { SigningMethod jwt.SigningMethod Audience string Issuer string MaxAge time.Duration Key *rsa.PrivateKey }
JWTTrackedRequestCodec encodes TrackedRequests as signed JWTs
func (JWTTrackedRequestCodec) Decode ¶
func (s JWTTrackedRequestCodec) Decode(signed string) (*TrackedRequest, error)
Decode returns a Tracked request from an encoded string.
func (JWTTrackedRequestCodec) Encode ¶
func (s JWTTrackedRequestCodec) Encode(value TrackedRequest) (string, error)
Encode returns an encoded string representing the TrackedRequest.
type RequestTracker ¶
type RequestTracker interface { // TrackRequest starts tracking the SAML request with the given ID. It returns an // `index` that should be used as the RelayState in the SAMl request flow. TrackRequest(w http.ResponseWriter, r *http.Request, samlRequestID string) (index string, err error) // StopTrackingRequest stops tracking the SAML request given by index, which is a string // previously returned from TrackRequest StopTrackingRequest(w http.ResponseWriter, r *http.Request, index string) error // GetTrackedRequests returns all the pending tracked requests GetTrackedRequests(r *http.Request) []TrackedRequest // GetTrackedRequest returns a pending tracked request. GetTrackedRequest(r *http.Request, index string) (*TrackedRequest, error) }
RequestTracker tracks pending authentication requests.
There are two main reasons for this:
When the middleware initiates an authentication request it must track the original URL in order to redirect the user to the right place after the authentication completes.
After the authentication completes, we want to ensure that the user presenting the assertion is actually the one the request it, to mitigate request forgeries.
type TrackedRequest ¶
type TrackedRequest struct { Index string `json:"-"` SAMLRequestID string `json:"id"` URI string `json:"uri"` }
TrackedRequest holds the data we store for each pending request.
type TrackedRequestCodec ¶
type TrackedRequestCodec interface { // Encode returns an encoded string representing the TrackedRequest. Encode(value TrackedRequest) (string, error) // Decode returns a Tracked request from an encoded string. Decode(signed string) (*TrackedRequest, error) }
TrackedRequestCodec handles encoding and decoding of a TrackedRequest.