summaryrefslogtreecommitdiff
path: root/internal/configuration/decode_hooks.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2023-05-15 10:03:19 +1000
committerGitHub <noreply@github.com>2023-05-15 10:03:19 +1000
commitcef374cdc184ca15fb516507d9f16356d15a0b95 (patch)
tree5190020d4dacf4c1b944961b3a790c3d39126833 /internal/configuration/decode_hooks.go
parent1dbfbc5f888f9d428ab023d0fd5919dd055b4354 (diff)
feat(oidc): multiple jwk algorithms (#5279)
This adds support for multiple JWK algorithms and keys and allows for per-client algorithm choices. Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Diffstat (limited to 'internal/configuration/decode_hooks.go')
-rw-r--r--internal/configuration/decode_hooks.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/configuration/decode_hooks.go b/internal/configuration/decode_hooks.go
index c9d4be4f5..2bcfb614c 100644
--- a/internal/configuration/decode_hooks.go
+++ b/internal/configuration/decode_hooks.go
@@ -513,6 +513,30 @@ func StringToCryptoPrivateKeyHookFunc() mapstructure.DecodeHookFuncType {
}
}
+// StringToCryptographicKeyHookFunc decodes strings to schema.CryptographicKey's.
+func StringToCryptographicKeyHookFunc() mapstructure.DecodeHookFuncType {
+ return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
+ if f.Kind() != reflect.String {
+ return data, nil
+ }
+
+ field, _ := reflect.TypeOf(schema.JWK{}).FieldByName("Key")
+ expectedType := field.Type
+
+ if t != expectedType {
+ return data, nil
+ }
+
+ dataStr := data.(string)
+
+ if value, err = utils.ParseX509FromPEM([]byte(dataStr)); err != nil {
+ return nil, fmt.Errorf(errFmtDecodeHookCouldNotParseBasic, "", expectedType, err)
+ }
+
+ return value, nil
+ }
+}
+
// StringToPrivateKeyHookFunc decodes strings to rsa.PrivateKey's.
func StringToPrivateKeyHookFunc() mapstructure.DecodeHookFuncType {
return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {