mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 14:55:42 +00:00
.
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
package keyfunc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
// ktyOct is the key type (kty) in the JWT header for oct.
|
||||
ktyOct = "oct"
|
||||
)
|
||||
|
||||
// Oct parses a jsonWebKey and turns it into a raw byte slice (octet). This includes HMAC keys.
|
||||
func (j *jsonWebKey) Oct() (publicKey []byte, err error) {
|
||||
if j.K == "" {
|
||||
return nil, fmt.Errorf("%w: %s", ErrMissingAssets, ktyOct)
|
||||
}
|
||||
|
||||
// Decode the octet key from Base64.
|
||||
//
|
||||
// According to RFC 7517, this is Base64 URL bytes.
|
||||
// https://datatracker.ietf.org/doc/html/rfc7517#section-1.1
|
||||
publicKey, err = base64urlTrailingPadding(j.K)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return publicKey, nil
|
||||
}
|
||||
Reference in New Issue
Block a user