Skip to content

Commit

Permalink
oauth2: propagate go context down the call path
Browse files Browse the repository at this point in the history
Signed-off-by: Amir Aslaminejad <aslaminejad@gmail.com>
  • Loading branch information
aaslamin authored and aeneasr committed Sep 21, 2018
1 parent a190bee commit 4188f69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions oauth2/handler.go
Expand Up @@ -281,13 +281,13 @@ func (h *Handler) UserinfoHandler(w http.ResponseWriter, r *http.Request) {
delete(interim, "exp")
delete(interim, "jti")

keyID, err := h.OpenIDJWTStrategy.GetPublicKeyID()
keyID, err := h.OpenIDJWTStrategy.GetPublicKeyID(r.Context())
if err != nil {
h.H.WriteError(w, r, err)
return
}

token, _, err := h.OpenIDJWTStrategy.Generate(jwt2.MapClaims(interim), &jwt.Headers{
token, _, err := h.OpenIDJWTStrategy.Generate(r.Context(), jwt2.MapClaims(interim), &jwt.Headers{
Extra: map[string]interface{}{
"kid": keyID,
},
Expand Down Expand Up @@ -526,7 +526,7 @@ func (h *Handler) TokenHandler(w http.ResponseWriter, r *http.Request) {
if accessRequest.GetGrantTypes().Exact("client_credentials") {
var accessTokenKeyID string
if h.AccessTokenStrategy == "jwt" {
accessTokenKeyID, err = h.AccessTokenJWTStrategy.GetPublicKeyID()
accessTokenKeyID, err = h.AccessTokenJWTStrategy.GetPublicKeyID(r.Context())
if err != nil {
pkg.LogError(err, h.L)
h.OAuth2.WriteAccessError(w, accessRequest, err)
Expand Down Expand Up @@ -599,7 +599,7 @@ func (h *Handler) AuthHandler(w http.ResponseWriter, r *http.Request, _ httprout
authorizeRequest.GrantScope(scope)
}

openIDKeyID, err := h.OpenIDJWTStrategy.GetPublicKeyID()
openIDKeyID, err := h.OpenIDJWTStrategy.GetPublicKeyID(r.Context())
if err != nil {
pkg.LogError(err, h.L)
h.writeAuthorizeError(w, authorizeRequest, err)
Expand All @@ -608,7 +608,7 @@ func (h *Handler) AuthHandler(w http.ResponseWriter, r *http.Request, _ httprout

var accessTokenKeyID string
if h.AccessTokenStrategy == "jwt" {
accessTokenKeyID, err = h.AccessTokenJWTStrategy.GetPublicKeyID()
accessTokenKeyID, err = h.AccessTokenJWTStrategy.GetPublicKeyID(r.Context())
if err != nil {
pkg.LogError(err, h.L)
h.writeAuthorizeError(w, authorizeRequest, err)
Expand Down
4 changes: 2 additions & 2 deletions oauth2/oauth2_auth_code_test.go
Expand Up @@ -124,11 +124,11 @@ func TestAuthCodeWithDefaultStrategy(t *testing.T) {
WorkFactor: 4,
}

fooUserIDToken, _, err := jwts.Generate((jwt.IDTokenClaims{
fooUserIDToken, _, err := jwts.Generate(context.TODO(), jwt.IDTokenClaims{
Subject: "foouser",
ExpiresAt: time.Now().Add(time.Hour),
IssuedAt: time.Now(),
}).ToMapClaims(), jwt.NewHeaders())
}.ToMapClaims(), jwt.NewHeaders())
require.NoError(t, err)

// we create a new fositeStore here because the old one
Expand Down

0 comments on commit 4188f69

Please sign in to comment.