Skip to content

Commit

Permalink
oauth2: pass the request context along to the sql store.
Browse files Browse the repository at this point in the history
Signed-off-by: Amir Aslaminejad <aslaminejad@gmail.com>
  • Loading branch information
aaslamin committed Sep 12, 2018
1 parent 91049a9 commit dde0593
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions oauth2/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package oauth2

import (
"context"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -342,7 +341,7 @@ func (h *Handler) UserinfoHandler(w http.ResponseWriter, r *http.Request) {
// 401: genericError
// 500: genericError
func (h *Handler) RevocationHandler(w http.ResponseWriter, r *http.Request) {
var ctx = fosite.NewContext()
var ctx = r.Context()

err := h.OAuth2.NewRevocationRequest(ctx, r)
if err != nil {
Expand Down Expand Up @@ -378,7 +377,7 @@ func (h *Handler) RevocationHandler(w http.ResponseWriter, r *http.Request) {
// 500: genericError
func (h *Handler) IntrospectHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
var session = NewSession("")
var ctx = fosite.NewContext()
var ctx = r.Context()

if r.Method != "POST" {
err := errors.WithStack(fosite.ErrInvalidRequest.WithHintf("HTTP method is \"%s\", expected \"POST\".", r.Method))
Expand Down Expand Up @@ -480,7 +479,7 @@ func (h *Handler) FlushHandler(w http.ResponseWriter, r *http.Request, _ httprou
fr.NotAfter = time.Now()
}

if err := h.Storage.FlushInactiveAccessTokens(context.Background(), fr.NotAfter); err != nil {
if err := h.Storage.FlushInactiveAccessTokens(r.Context(), fr.NotAfter); err != nil {
h.H.WriteError(w, r, err)
return
}
Expand Down Expand Up @@ -515,7 +514,7 @@ func (h *Handler) FlushHandler(w http.ResponseWriter, r *http.Request, _ httprou
// 500: genericError
func (h *Handler) TokenHandler(w http.ResponseWriter, r *http.Request) {
var session = NewSession("")
var ctx = fosite.NewContext()
var ctx = r.Context()

accessRequest, err := h.OAuth2.NewAccessRequest(ctx, r, session)
if err != nil {
Expand Down Expand Up @@ -577,7 +576,7 @@ func (h *Handler) TokenHandler(w http.ResponseWriter, r *http.Request) {
// 401: genericError
// 500: genericError
func (h *Handler) AuthHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
var ctx = fosite.NewContext()
var ctx = r.Context()

authorizeRequest, err := h.OAuth2.NewAuthorizeRequest(ctx, r)
if err != nil {
Expand Down

0 comments on commit dde0593

Please sign in to comment.