Skip to content

Commit

Permalink
Merge pull request #37 from janekolszak/devel
Browse files Browse the repository at this point in the history
Added context, updated to Hydra 0.9.x
  • Loading branch information
janekolszak authored Jun 12, 2017
2 parents efef485 + 139f121 commit a4ef1ea
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 42 deletions.
79 changes: 42 additions & 37 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import:
- package: github.com/gorilla/sessions
version: ~1.1.0
- package: github.com/ory/hydra
version: ~0.8.5
version: ~0.9.0
subpackages:
- client
- jwk
Expand Down
9 changes: 5 additions & 4 deletions idp.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package idp

import (
"context"
"crypto/rsa"
"net/http"
"time"
Expand Down Expand Up @@ -260,7 +261,7 @@ func (idp *IDP) getVerificationKey() (*rsa.PublicKey, error) {
return key, nil
}

func (idp *IDP) getClient(clientID string) (*hclient.Client, error) {
func (idp *IDP) getClient(ctx context.Context, clientID string) (*hclient.Client, error) {
clientKey := ClientInfoKey(clientID)
data, ok := idp.cache.Get(clientKey)
if ok {
Expand All @@ -271,7 +272,7 @@ func (idp *IDP) getClient(clientID string) (*hclient.Client, error) {
return nil, ErrorNoSuchClient
}

client, err := idp.hc.Clients.GetClient(clientID)
client, err := idp.hc.Clients.GetClient(ctx, clientID)
if err != nil {
// Either the client isn't registered in hydra, or maybe hydra is
// having some problem. Either way, ensure we don't hit hydra again
Expand All @@ -286,7 +287,7 @@ func (idp *IDP) getClient(clientID string) (*hclient.Client, error) {
}

// Create a new Challenge. The request will contain all the necessary information from Hydra, passed in the URL.
func (idp *IDP) NewChallenge(r *http.Request, user string) (challenge *Challenge, err error) {
func (idp *IDP) NewChallenge(ctx context.Context, r *http.Request, user string) (challenge *Challenge, err error) {
tokenStr := r.FormValue("challenge")
if tokenStr == "" {
// No challenge token
Expand All @@ -310,7 +311,7 @@ func (idp *IDP) NewChallenge(r *http.Request, user string) (challenge *Challenge
}

// Get data from the challenge jwt
challenge.Client, err = idp.getClient(claims["aud"].(string))
challenge.Client, err = idp.getClient(ctx, claims["aud"].(string))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit a4ef1ea

Please sign in to comment.