refactor(auth): replace untyped JWT claims with typed Claims struct
Introduced a typed Claims struct in core/auth to replace the raw map[string]any approach used for JWT claims throughout the codebase. This provides compile-time safety and better readability when creating, validating, and extracting JWT tokens. Also upgraded lestrrat-go/jwx from v2 to v3 and go-chi/jwtauth to v5.4.0, adapting all callers to the new API where token accessor methods now return tuples instead of bare values. Updated all affected handlers, middleware, and tests. Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -229,11 +229,10 @@ func decodeArtworkURL(artworkURL string) model.ArtworkID {
|
||||
token, err := auth.TokenAuth.Decode(tokenPart)
|
||||
Expect(err).ToNot(HaveOccurred(), "Failed to decode JWT token")
|
||||
|
||||
claims, err := token.AsMap(context.Background())
|
||||
Expect(err).ToNot(HaveOccurred(), "Failed to get claims from token")
|
||||
c := auth.ClaimsFromToken(token)
|
||||
|
||||
id, ok := claims["id"].(string)
|
||||
Expect(ok).To(BeTrue(), "Token should contain 'id' claim")
|
||||
id := c.ID
|
||||
Expect(id).ToNot(BeEmpty(), "Token should contain 'id' claim")
|
||||
|
||||
artID, err := model.ParseArtworkID(id)
|
||||
Expect(err).ToNot(HaveOccurred(), "Failed to parse artwork ID from token")
|
||||
|
||||
Reference in New Issue
Block a user