1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-24 05:17:03 +00:00

update dependencies

This commit is contained in:
Gerasimos (Makis) Maropoulos
2025-08-15 23:29:20 +03:00
parent de4f462198
commit a8a3afea22
186 changed files with 694 additions and 689 deletions

View File

@@ -352,7 +352,7 @@ func main() {
// You can also register the pre-defined jwt middleware for all protected routes
// which performs verification automatically and set the custom Claims to the Context
// for next handlers to use through: claims := jwt.Get(ctx).(*Claims).
app.Use(accessVerifier.Verify(func() interface{} {
app.Use(accessVerifier.Verify(func() any {
return new(Claims)
}))

View File

@@ -36,7 +36,7 @@ func TestJWT(t *testing.T) {
verifier.ErrorHandler = func(ctx iris.Context, err error) { // app.OnErrorCode(401, ...)
ctx.StopWithError(iris.StatusUnauthorized, err)
}
middleware := verifier.Verify(func() interface{} { return new(fooClaims) })
middleware := verifier.Verify(func() any { return new(fooClaims) })
app.Get("/protected", middleware, func(ctx iris.Context) {
claims := jwt.Get(ctx).(*fooClaims)
ctx.WriteString(claims.Foo)

View File

@@ -14,7 +14,7 @@ import (
// It does not support JWE, JWK.
type Signer struct {
Alg Alg
Key interface{}
Key any
// MaxAge to set "exp" and "iat".
// Recommended value for access tokens: 15 minutes.
@@ -33,7 +33,7 @@ type Signer struct {
//
// signer := NewSigner(HS256, secret, 15*time.Minute)
// token, err := signer.Sign(userClaims{Username: "kataras"})
func NewSigner(signatureAlg Alg, signatureKey interface{}, maxAge time.Duration) *Signer {
func NewSigner(signatureAlg Alg, signatureKey any, maxAge time.Duration) *Signer {
if signatureAlg == HS256 {
// A tiny helper if the end-developer uses string instead of []byte for hmac keys.
if k, ok := signatureKey.(string); ok {
@@ -66,7 +66,7 @@ func (s *Signer) WithEncryption(key, additionalData []byte) *Signer {
}
// Sign generates a new token based on the given "claims" which is valid up to "s.MaxAge".
func (s *Signer) Sign(claims interface{}, opts ...SignOption) ([]byte, error) {
func (s *Signer) Sign(claims any, opts ...SignOption) ([]byte, error) {
if len(opts) > 0 {
opts = append(opts, s.Options...)
} else {
@@ -79,7 +79,7 @@ func (s *Signer) Sign(claims interface{}, opts ...SignOption) ([]byte, error) {
// NewTokenPair accepts the access and refresh claims plus the life time duration for the refresh token
// and generates a new token pair which can be sent to the client.
// The same token pair can be json-decoded.
func (s *Signer) NewTokenPair(accessClaims interface{}, refreshClaims interface{}, refreshMaxAge time.Duration, accessOpts ...SignOption) (TokenPair, error) {
func (s *Signer) NewTokenPair(accessClaims any, refreshClaims any, refreshMaxAge time.Duration, accessOpts ...SignOption) (TokenPair, error) {
if refreshMaxAge <= s.MaxAge {
return TokenPair{}, fmt.Errorf("refresh max age should be bigger than access token's one[%d - %d]", refreshMaxAge, s.MaxAge)
}

View File

@@ -15,7 +15,7 @@ const (
)
// Get returns the claims decoded by a verifier.
func Get(ctx *context.Context) interface{} {
func Get(ctx *context.Context) any {
if v := ctx.Values().Get(claimsContextKey); v != nil {
return v
}
@@ -42,7 +42,7 @@ func GetVerifiedToken(ctx *context.Context) *VerifiedToken {
// It does not support JWE, JWK.
type Verifier struct {
Alg Alg
Key interface{}
Key any
Decrypt func([]byte) ([]byte, error)
@@ -67,7 +67,7 @@ type Verifier struct {
//
// verifier := NewVerifier(HS256, secret, Expected{Issuer: "my-app"})
//
// claimsGetter := func() interface{} { return new(userClaims) }
// claimsGetter := func() any { return new(userClaims) }
// middleware := verifier.Verify(claimsGetter)
//
// OR
@@ -86,7 +86,7 @@ type Verifier struct {
// Get the context user:
//
// username, err := ctx.User().GetUsername()
func NewVerifier(signatureAlg Alg, signatureKey interface{}, validators ...TokenValidator) *Verifier {
func NewVerifier(signatureAlg Alg, signatureKey any, validators ...TokenValidator) *Verifier {
if signatureAlg == HS256 {
// A tiny helper if the end-developer uses string instead of []byte for hmac keys.
if k, ok := signatureKey.(string); ok {
@@ -183,7 +183,7 @@ func (v *Verifier) VerifyToken(token []byte, validators ...TokenValidator) (*Ver
//
// If the "claimsType" is nil then only the jwt.GetVerifiedToken is available
// and the handler should unmarshal the payload to extract the claims by itself.
func (v *Verifier) Verify(claimsType func() interface{}, validators ...TokenValidator) context.Handler {
func (v *Verifier) Verify(claimsType func() any, validators ...TokenValidator) context.Handler {
unmarshal := jwt.Unmarshal
if claimsType != nil {
c := claimsType()
@@ -252,7 +252,7 @@ func (v *Verifier) Verify(claimsType func() interface{}, validators ...TokenVali
}
}
func hasRequired(i interface{}) bool {
func hasRequired(i any) bool {
val := reflect.Indirect(reflect.ValueOf(i))
typ := val.Type()
if typ.Kind() != reflect.Struct {