CreateSessionFromAssertion is invoked by ServeHTTP when we have a new, valid SAML assertion.
(w http.ResponseWriter, r *http.Request, assertion *saml.Assertion, redirectURI string)
| 183 | |
| 184 | // CreateSessionFromAssertion is invoked by ServeHTTP when we have a new, valid SAML assertion. |
| 185 | func (m *Middleware) CreateSessionFromAssertion(w http.ResponseWriter, r *http.Request, assertion *saml.Assertion, redirectURI string) { |
| 186 | if trackedRequestIndex := r.Form.Get("RelayState"); trackedRequestIndex != "" { |
| 187 | trackedRequest, err := m.RequestTracker.GetTrackedRequest(r, trackedRequestIndex) |
| 188 | if err != nil { |
| 189 | if err == http.ErrNoCookie && m.ServiceProvider.AllowIDPInitiated { |
| 190 | if uri := r.Form.Get("RelayState"); uri != "" { |
| 191 | redirectURI = uri |
| 192 | } |
| 193 | } else { |
| 194 | m.OnError(w, r, err) |
| 195 | return |
| 196 | } |
| 197 | } else { |
| 198 | m.RequestTracker.StopTrackingRequest(w, r, trackedRequestIndex) |
| 199 | |
| 200 | redirectURI = trackedRequest.URI |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | if err := m.Session.CreateSession(w, r, assertion); err != nil { |
| 205 | m.OnError(w, r, err) |
| 206 | return |
| 207 | } |
| 208 | |
| 209 | http.Redirect(w, r, redirectURI, http.StatusFound) |
| 210 | } |
| 211 | |
| 212 | // RequireAttribute returns a middleware function that requires that the |
| 213 | // SAML attribute `name` be set to `value`. This can be used to require |
no test coverage detected