mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-08 16:39:35 +00:00
75513575be
* store dependency's in git * since we vendor ... rm tech-depts * aad make target 'vendor' to update vendor folder (manual task)
25 lines
677 B
Go
25 lines
677 B
Go
package jwt
|
|
|
|
var signingMethods = map[string]func() SigningMethod{}
|
|
|
|
// Signing method
|
|
type SigningMethod interface {
|
|
Verify(signingString, signature string, key interface{}) error
|
|
Sign(signingString string, key interface{}) (string, error)
|
|
Alg() string
|
|
}
|
|
|
|
// Register the "alg" name and a factory function for signing method.
|
|
// This is typically done during init() in the method's implementation
|
|
func RegisterSigningMethod(alg string, f func() SigningMethod) {
|
|
signingMethods[alg] = f
|
|
}
|
|
|
|
// Get a signing method from an "alg" string
|
|
func GetSigningMethod(alg string) (method SigningMethod) {
|
|
if methodF, ok := signingMethods[alg]; ok {
|
|
method = methodF()
|
|
}
|
|
return
|
|
}
|