feat: initial commit

This commit is contained in:
2025-03-31 16:17:35 +01:00
commit 6719f8a61a
91 changed files with 7119 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
package auth
import (
"time"
"github.com/golang-jwt/jwt/v5"
)
type TestAuthenticator struct {
}
const testToken = "test-token"
var testClaims = jwt.MapClaims{
"aud": "test-audience",
"iss": "test-issuer",
"sub": 1,
"exp": time.Now().Add(time.Hour * 24).Unix(),
}
func (a *TestAuthenticator) GenerateToken(claims jwt.Claims) (string, error) {
token := jwt.NewWithClaims(jwt.SigningMethodHS256, testClaims)
return token.SignedString([]byte(testToken))
}
func (a *TestAuthenticator) ValidateToken(token string) (*jwt.Token, error) {
return jwt.Parse(token, func(token *jwt.Token) (any, error) {
return []byte(testToken), nil
})
}