* introspect * introspect and client assertion * introspect and client assertion * scopes * token introspection * introspect * refactoring * fixes * clenaup * Update example/internal/mock/storage.go Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com> * clenaup Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com>
33 lines
653 B
Go
33 lines
653 B
Go
package oidc
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
|
|
"github.com/caos/oidc/pkg/utils"
|
|
)
|
|
|
|
const (
|
|
CodeChallengeMethodPlain CodeChallengeMethod = "plain"
|
|
CodeChallengeMethodS256 CodeChallengeMethod = "S256"
|
|
)
|
|
|
|
type CodeChallengeMethod string
|
|
|
|
type CodeChallenge struct {
|
|
Challenge string
|
|
Method CodeChallengeMethod
|
|
}
|
|
|
|
func NewSHACodeChallenge(code string) string {
|
|
return utils.HashString(sha256.New(), code, false)
|
|
}
|
|
|
|
func VerifyCodeChallenge(c *CodeChallenge, codeVerifier string) bool {
|
|
if c == nil {
|
|
return false
|
|
}
|
|
if c.Method == CodeChallengeMethodS256 {
|
|
codeVerifier = NewSHACodeChallenge(codeVerifier)
|
|
}
|
|
return codeVerifier == c.Challenge
|
|
}
|