Skip to content

Commit

Permalink
Change VerifyHeroku to Verify, and remove Verify.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyp committed Mar 15, 2024
1 parent 1910815 commit 91aad96
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions dynoid/dynoid.go
Expand Up @@ -164,7 +164,7 @@ func ReadLocalToken(ctx context.Context, audience string) (*Token, error) {

verifier := NewWithCallback(audience, func(issuer string) error { return nil })

return verifier.VerifyHeroku(ctx, rawToken)
return verifier.Verify(ctx, rawToken)
}

// AllowHerokuSpace verifies that the issuer is from Heroku for the given host
Expand Down Expand Up @@ -213,7 +213,7 @@ func NewWithCallback(clientID string, callback IssuerCallback) *Verifier {

// Verify validates the given token with the OIDC provider and validates it
// against the IssuerCallback
func (v *Verifier) Verify(ctx context.Context, rawIDToken string) (*oidc.IDToken, error) {
func (v *Verifier) Verify(ctx context.Context, rawIDToken string) (*Token, error) {
if v == nil {
*v = *New("")
}
Expand All @@ -238,13 +238,7 @@ func (v *Verifier) Verify(ctx context.Context, rawIDToken string) (*oidc.IDToken

verifier := provider.Verifier(v.config)

return verifier.Verify(ctx, rawIDToken)
}

// VerifyHeroku verifies the token and parses the returned issuer and subject
// according to Heroku expected values
func (v *Verifier) VerifyHeroku(ctx context.Context, rawIDToken string) (*Token, error) {
token, err := v.Verify(ctx, rawIDToken)
token, err := verifier.Verify(ctx, rawIDToken)
if err != nil {
return nil, fmt.Errorf("failed to verify token (%w)", err)
}
Expand Down
2 changes: 1 addition & 1 deletion dynoid/middleware/dynoid.go
Expand Up @@ -98,7 +98,7 @@ func populateDynoID(audience string, callback dynoid.IssuerCallback) func(*http.
return r.WithContext(AddToContext(ctx, nil, ErrTokenMissing))
}

token, err := verifier.VerifyHeroku(r.Context(), rawToken)
token, err := verifier.Verify(r.Context(), rawToken)

return r.WithContext(AddToContext(ctx, token, err))
}
Expand Down

0 comments on commit 91aad96

Please sign in to comment.