mirror of
https://github.com/jonasroussel/dart_jsonwebtoken.git
synced 2025-08-24 13:01:26 +08:00
Set parameters when using JWT.decode
Set audience, issuer, subject and jwtId when using the JWT.decode function
This commit is contained in:
@ -188,6 +188,9 @@ class JWT {
|
||||
}
|
||||
|
||||
/// Decode a token without checking its signature
|
||||
///
|
||||
/// This also sets [JWT.audience], [JWT.subject], [JWT.issuer], and
|
||||
/// [JWT.jwtId] even though they are not verified. Use with caution.
|
||||
static JWT decode(String token) {
|
||||
try {
|
||||
final parts = token.split('.');
|
||||
@ -207,6 +210,10 @@ class JWT {
|
||||
return JWT(
|
||||
payload,
|
||||
header: header,
|
||||
audience: _parseAud(payload['aud']),
|
||||
issuer: payload['iss']?.toString(),
|
||||
subject: payload['sub']?.toString(),
|
||||
jwtId: payload['jti']?.toString(),
|
||||
);
|
||||
}
|
||||
} catch (ex, stackTrace) {
|
||||
|
Reference in New Issue
Block a user