appleboy / appleboy/gin-jwt

Empty claims when extracting claims inside Authenticator.

Open
#206 0 comments 4 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3k
Forks
387
Avg merge
4h 16m
Merged PRs (30d)
1

Description

I am trying to extract claims inside the Authenticator, to perform certain operations right after successful authentication - Login.

However I am getting empty claims everytime I extract them using the Extractclaims() method.

However I get the proper claim values in the Authorizatior.

```go
Authenticator: func(c *gin.Context) (interface{}, error) {
claims := jwt.ExtractClaims(c)
fmt.Println(claims["id"].(string))
}
```

I get nil for claim value inside authenticator.

```go
Authorizator: func(data interface{}, c *gin.Context) bool {
claims := jwt.ExtractClaims(c)
fmt.Println(claims["id"].(string))
},
```

I am getting the Id when using with Authorizatior.

Also the context body is right.

What am I missing?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing ExtractClaims(c) from the Authenticator callback and compare the Gin context state there with the Authorizator callback, using the reproduction snippets in the issue. Determine whether claims should be available during authentication, then add or update the relevant test or behavior so the expected claim visibility is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
authentication, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.