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>
27 lines
507 B
Go
27 lines
507 B
Go
package crypto
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
|
|
"gopkg.in/square/go-jose.v2"
|
|
)
|
|
|
|
func Sign(object any, signer jose.Signer) (string, error) {
|
|
payload, err := json.Marshal(object)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return SignPayload(payload, signer)
|
|
}
|
|
|
|
func SignPayload(payload []byte, signer jose.Signer) (string, error) {
|
|
if signer == nil {
|
|
return "", errors.New("missing signer")
|
|
}
|
|
result, err := signer.Sign(payload)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return result.CompactSerialize()
|
|
}
|