JWT Claims

mac2022-06-30  261

JWT Claims

“iss” (issuer)  发行人

“sub” (subject)  主题

“aud” (audience) 接收方 用户

“exp” (expiration time) 到期时间

“nbf” (not before)  在此之前不可用

“iat” (issued at)  jwt的签发时间

“jti” (JWT ID)  jwt的唯一身份标识,主要用来作为一次性token,从而回避重放攻击。

/// <summary> /// JSON Web Token (JWT) claims set. /// </summary> TJWTClaims = class(TJOSEBase) private const AUDIENCE_SEPARATOR = ','; private function GetAudience: string; function GetExpiration: TDateTime; function GetIssuedAt: TDateTime; function GetIssuer: string; function GetJWTId: string; function GetNotBefore: TDateTime; function GetSubject: string; procedure SetAudience(Value: string); procedure SetExpiration(Value: TDateTime); procedure SetIssuedAt(Value: TDateTime); procedure SetIssuer(Value: string); procedure SetJWTId(Value: string); procedure SetNotBefore(Value: TDateTime); procedure SetSubject(Value: string); function GetHasAudience: Boolean; function GetHasExpiration: Boolean; function GetHasIssuedAt: Boolean; function GetHasIssuer: Boolean; function GetHasJWTId: Boolean; function GetHasNotBefore: Boolean; function GetHasSubject: Boolean; function ClaimExists(const AClaimName: string): Boolean; function GetAudienceArray: TArray<string>; procedure SetAudienceArray(const Value: TArray<string>); public constructor Create; virtual; procedure SetClaimOfType<T>(const AName: string; const AValue: T); function GenerateJWTId(ANumberOfBytes: Integer = 16): string; property Audience: string read GetAudience write SetAudience; property AudienceArray: TArray<string> read GetAudienceArray write SetAudienceArray; property HasAudience: Boolean read GetHasAudience; property Expiration: TDateTime read GetExpiration write SetExpiration; property HasExpiration: Boolean read GetHasExpiration; property IssuedAt: TDateTime read GetIssuedAt write SetIssuedAt; property HasIssuedAt: Boolean read GetHasIssuedAt; property Issuer: string read GetIssuer write SetIssuer; property HasIssuer: Boolean read GetHasIssuer; property JWTId: string read GetJWTId write SetJWTId; property HasJWTId: Boolean read GetHasJWTId; property NotBefore: TDateTime read GetNotBefore write SetNotBefore; property HasNotBefore: Boolean read GetHasNotBefore; property Subject: string read GetSubject write SetSubject; property HasSubject: Boolean read GetHasSubject; end;

  

 

转载于:https://www.cnblogs.com/hnxxcxg/p/11367704.html

相关资源:JWT帮助文档

最新回复(0)