zitadel-oidc/pkg/op/signer.go
Thomas Hipp e6e3835362
chore: replace interface{} with any (#448)
This PR replaces all occurances of interface{} with any to be consistent and improve readability.

* example: Replace `interface{}` with `any`

Signed-off-by: Thomas Hipp <thomashipp@gmail.com>

* pkg/client: Replace `interface{}` with `any`

Signed-off-by: Thomas Hipp <thomashipp@gmail.com>

* pkg/crypto: Replace `interface{}` with `any`

Signed-off-by: Thomas Hipp <thomashipp@gmail.com>

* pkg/http: Replace `interface{}` with `any`

Signed-off-by: Thomas Hipp <thomashipp@gmail.com>

* pkg/oidc: Replace `interface{}` with `any`

Signed-off-by: Thomas Hipp <thomashipp@gmail.com>

* pkg/op: Replace `interface{}` with `any`

Signed-off-by: Thomas Hipp <thomashipp@gmail.com>

---------

Signed-off-by: Thomas Hipp <thomashipp@gmail.com>
2023-10-12 12:41:04 +03:00

36 lines
701 B
Go

package op
import (
"errors"
"gopkg.in/square/go-jose.v2"
)
var ErrSignerCreationFailed = errors.New("signer creation failed")
type SigningKey interface {
SignatureAlgorithm() jose.SignatureAlgorithm
Key() any
ID() string
}
func SignerFromKey(key SigningKey) (jose.Signer, error) {
signer, err := jose.NewSigner(jose.SigningKey{
Algorithm: key.SignatureAlgorithm(),
Key: &jose.JSONWebKey{
Key: key.Key(),
KeyID: key.ID(),
},
}, (&jose.SignerOptions{}).WithType("JWT"))
if err != nil {
return nil, ErrSignerCreationFailed // TODO: log / wrap error?
}
return signer, nil
}
type Key interface {
ID() string
Algorithm() jose.SignatureAlgorithm
Use() string
Key() any
}