mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
fix typo: say good bye to the singing key (#10966)
Polish a glitch from #10481 (kinda sad to let go of such a cute name) ### Checklist * no tests to change * no docs to change * not relevant for release notes Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10966 Reviewed-by: Lucas <sclu1034@noreply.codeberg.org> Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Nils Goroll <nils.goroll@uplex.de> Co-committed-by: Nils Goroll <nils.goroll@uplex.de>
This commit is contained in:
parent
da7ce17533
commit
7c7d506386
1 changed files with 24 additions and 24 deletions
|
|
@ -74,42 +74,42 @@ func (key hmacSigningKey) ToJWK() (map[string]string, error) {
|
|||
|
||||
func (key hmacSigningKey) PreProcessToken(*jwt.Token) {}
|
||||
|
||||
type rsaSingingKey struct {
|
||||
type rsaSigningKey struct {
|
||||
signingMethod jwt.SigningMethod
|
||||
key *rsa.PrivateKey
|
||||
id string
|
||||
}
|
||||
|
||||
func newRSASingingKey(signingMethod jwt.SigningMethod, key *rsa.PrivateKey) (rsaSingingKey, error) {
|
||||
func newRSASigningKey(signingMethod jwt.SigningMethod, key *rsa.PrivateKey) (rsaSigningKey, error) {
|
||||
kid, err := util.CreatePublicKeyFingerprint(key.Public().(*rsa.PublicKey))
|
||||
if err != nil {
|
||||
return rsaSingingKey{}, err
|
||||
return rsaSigningKey{}, err
|
||||
}
|
||||
|
||||
return rsaSingingKey{
|
||||
return rsaSigningKey{
|
||||
signingMethod,
|
||||
key,
|
||||
base64.RawURLEncoding.EncodeToString(kid),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (key rsaSingingKey) IsSymmetric() bool {
|
||||
func (key rsaSigningKey) IsSymmetric() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (key rsaSingingKey) SigningMethod() jwt.SigningMethod {
|
||||
func (key rsaSigningKey) SigningMethod() jwt.SigningMethod {
|
||||
return key.signingMethod
|
||||
}
|
||||
|
||||
func (key rsaSingingKey) SignKey() any {
|
||||
func (key rsaSigningKey) SignKey() any {
|
||||
return key.key
|
||||
}
|
||||
|
||||
func (key rsaSingingKey) VerifyKey() any {
|
||||
func (key rsaSigningKey) VerifyKey() any {
|
||||
return key.key.Public()
|
||||
}
|
||||
|
||||
func (key rsaSingingKey) ToJWK() (map[string]string, error) {
|
||||
func (key rsaSigningKey) ToJWK() (map[string]string, error) {
|
||||
pubKey := key.key.Public().(*rsa.PublicKey)
|
||||
|
||||
return map[string]string{
|
||||
|
|
@ -121,7 +121,7 @@ func (key rsaSingingKey) ToJWK() (map[string]string, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (key rsaSingingKey) PreProcessToken(token *jwt.Token) {
|
||||
func (key rsaSigningKey) PreProcessToken(token *jwt.Token) {
|
||||
token.Header["kid"] = key.id
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ type eddsaSigningKey struct {
|
|||
id string
|
||||
}
|
||||
|
||||
func newEdDSASingingKey(signingMethod jwt.SigningMethod, key ed25519.PrivateKey) (eddsaSigningKey, error) {
|
||||
func newEdDSASigningKey(signingMethod jwt.SigningMethod, key ed25519.PrivateKey) (eddsaSigningKey, error) {
|
||||
kid, err := util.CreatePublicKeyFingerprint(key.Public().(ed25519.PublicKey))
|
||||
if err != nil {
|
||||
return eddsaSigningKey{}, err
|
||||
|
|
@ -176,42 +176,42 @@ func (key eddsaSigningKey) PreProcessToken(token *jwt.Token) {
|
|||
token.Header["kid"] = key.id
|
||||
}
|
||||
|
||||
type ecdsaSingingKey struct {
|
||||
type ecdsaSigningKey struct {
|
||||
signingMethod jwt.SigningMethod
|
||||
key *ecdsa.PrivateKey
|
||||
id string
|
||||
}
|
||||
|
||||
func newECDSASingingKey(signingMethod jwt.SigningMethod, key *ecdsa.PrivateKey) (ecdsaSingingKey, error) {
|
||||
func newECDSASigningKey(signingMethod jwt.SigningMethod, key *ecdsa.PrivateKey) (ecdsaSigningKey, error) {
|
||||
kid, err := util.CreatePublicKeyFingerprint(key.Public().(*ecdsa.PublicKey))
|
||||
if err != nil {
|
||||
return ecdsaSingingKey{}, err
|
||||
return ecdsaSigningKey{}, err
|
||||
}
|
||||
|
||||
return ecdsaSingingKey{
|
||||
return ecdsaSigningKey{
|
||||
signingMethod,
|
||||
key,
|
||||
base64.RawURLEncoding.EncodeToString(kid),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (key ecdsaSingingKey) IsSymmetric() bool {
|
||||
func (key ecdsaSigningKey) IsSymmetric() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (key ecdsaSingingKey) SigningMethod() jwt.SigningMethod {
|
||||
func (key ecdsaSigningKey) SigningMethod() jwt.SigningMethod {
|
||||
return key.signingMethod
|
||||
}
|
||||
|
||||
func (key ecdsaSingingKey) SignKey() any {
|
||||
func (key ecdsaSigningKey) SignKey() any {
|
||||
return key.key
|
||||
}
|
||||
|
||||
func (key ecdsaSingingKey) VerifyKey() any {
|
||||
func (key ecdsaSigningKey) VerifyKey() any {
|
||||
return key.key.Public()
|
||||
}
|
||||
|
||||
func (key ecdsaSingingKey) ToJWK() (map[string]string, error) {
|
||||
func (key ecdsaSigningKey) ToJWK() (map[string]string, error) {
|
||||
pubKey := key.key.Public().(*ecdsa.PublicKey)
|
||||
|
||||
return map[string]string{
|
||||
|
|
@ -224,7 +224,7 @@ func (key ecdsaSingingKey) ToJWK() (map[string]string, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (key ecdsaSingingKey) PreProcessToken(token *jwt.Token) {
|
||||
func (key ecdsaSigningKey) PreProcessToken(token *jwt.Token) {
|
||||
token.Header["kid"] = key.id
|
||||
}
|
||||
|
||||
|
|
@ -264,19 +264,19 @@ func CreateSigningKey(algorithm string, key any) (SigningKey, error) {
|
|||
if !ok {
|
||||
return nil, jwt.ErrInvalidKeyType
|
||||
}
|
||||
return newEdDSASingingKey(signingMethod, privateKey)
|
||||
return newEdDSASigningKey(signingMethod, privateKey)
|
||||
case *jwt.SigningMethodECDSA:
|
||||
privateKey, ok := key.(*ecdsa.PrivateKey)
|
||||
if !ok {
|
||||
return nil, jwt.ErrInvalidKeyType
|
||||
}
|
||||
return newECDSASingingKey(signingMethod, privateKey)
|
||||
return newECDSASigningKey(signingMethod, privateKey)
|
||||
case *jwt.SigningMethodRSA:
|
||||
privateKey, ok := key.(*rsa.PrivateKey)
|
||||
if !ok {
|
||||
return nil, jwt.ErrInvalidKeyType
|
||||
}
|
||||
return newRSASingingKey(signingMethod, privateKey)
|
||||
return newRSASigningKey(signingMethod, privateKey)
|
||||
default:
|
||||
secret, ok := key.([]byte)
|
||||
if !ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue