swagger:route GET /oauth2/auth oAuth2 oAuth2Authorize # OAuth 2.0 Authorize Endpoint Use open source libraries to perform OAuth 2.0 and OpenID Connect available for any programming language. You can find a list of libraries at https://oauth.net/code/ This endpoint should not be used via the Ory S
(w http.ResponseWriter, r *http.Request)
| 1286 | // Extensions: |
| 1287 | // x-ory-ratelimit-bucket: hydra-public-medium |
| 1288 | func (h *Handler) oAuth2Authorize(w http.ResponseWriter, r *http.Request) { |
| 1289 | ctx := r.Context() |
| 1290 | |
| 1291 | authorizeRequest, err := h.r.OAuth2Provider().NewAuthorizeRequest(ctx, r) |
| 1292 | if err != nil { |
| 1293 | x.LogError(r, err, h.r.Logger()) |
| 1294 | h.writeAuthorizeError(w, r, authorizeRequest, err) |
| 1295 | return |
| 1296 | } |
| 1297 | |
| 1298 | fl, err := h.r.ConsentStrategy().HandleOAuth2AuthorizationRequest(ctx, w, r, authorizeRequest) |
| 1299 | if errors.Is(err, consent.ErrAbortOAuth2Request) { |
| 1300 | x.LogError(r, err, h.r.Logger()) |
| 1301 | // do nothing |
| 1302 | return |
| 1303 | } else if e := &(fosite.RFC6749Error{}); errors.As(err, &e) { |
| 1304 | x.LogError(r, err, h.r.Logger()) |
| 1305 | h.writeAuthorizeError(w, r, authorizeRequest, err) |
| 1306 | return |
| 1307 | } else if err != nil { |
| 1308 | x.LogError(r, err, h.r.Logger()) |
| 1309 | h.writeAuthorizeError(w, r, authorizeRequest, err) |
| 1310 | return |
| 1311 | } |
| 1312 | |
| 1313 | authorizeRequest.SetID(fl.ConsentRequestID.String()) |
| 1314 | session, err := h.updateSessionWithRequest(ctx, fl, r, authorizeRequest, nil) |
| 1315 | if err != nil { |
| 1316 | h.writeAuthorizeError(w, r, authorizeRequest, err) |
| 1317 | return |
| 1318 | } |
| 1319 | var response fosite.AuthorizeResponder |
| 1320 | if err := h.r.Transaction(ctx, func(ctx context.Context) (err error) { |
| 1321 | response, err = h.r.OAuth2Provider().NewAuthorizeResponse(ctx, authorizeRequest, session) |
| 1322 | return err |
| 1323 | }); err != nil { |
| 1324 | x.LogError(r, err, h.r.Logger()) |
| 1325 | h.writeAuthorizeError(w, r, authorizeRequest, err) |
| 1326 | return |
| 1327 | } |
| 1328 | |
| 1329 | h.r.OAuth2Provider().WriteAuthorizeResponse(ctx, w, authorizeRequest, response) |
| 1330 | } |
| 1331 | |
| 1332 | // Delete OAuth 2.0 Access Token Parameters |
| 1333 | // |
nothing calls this directly
no test coverage detected