From d104c98969b9c326d174ed396e36ea247e9c54fd Mon Sep 17 00:00:00 2001 From: Franco Fung <38921563+FuPingFranco@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:23:42 -0700 Subject: [PATCH] Adding Missing Standard Claims (#2623) * Added missing standard claims. * Clean-up * Clean-up * Addressing feedback --------- Co-authored-by: Franco Fung --- .../JwtRegisteredClaimNames.cs | 53 +++++++++++++- .../JwtRegisteredClaimNames.cs | 70 ++++++++++++++++++- 2 files changed, 119 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/JwtRegisteredClaimNames.cs b/src/Microsoft.IdentityModel.JsonWebTokens/JwtRegisteredClaimNames.cs index e9f9094578..ec4dabf45b 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/JwtRegisteredClaimNames.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/JwtRegisteredClaimNames.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Text; namespace Microsoft.IdentityModel.JsonWebTokens { @@ -10,6 +9,7 @@ namespace Microsoft.IdentityModel.JsonWebTokens /// List of registered claims from different sources /// https://datatracker.ietf.org/doc/html/rfc7519#section-4 /// http://openid.net/specs/openid-connect-core-1_0.html#IDToken + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims /// public struct JwtRegisteredClaimNames { @@ -24,6 +24,11 @@ public struct JwtRegisteredClaimNames /// public const string Acr = "acr"; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string Address = "address"; + /// /// http://openid.net/specs/openid-connect-core-1_0.html#IDToken /// @@ -64,6 +69,11 @@ public struct JwtRegisteredClaimNames /// public const string Email = "email"; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string EmailVerified = "email_verified"; + /// /// https://datatracker.ietf.org/doc/html/rfc7519#section-4 /// @@ -99,6 +109,16 @@ public struct JwtRegisteredClaimNames /// public const string Jti = "jti"; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string Locale = "locale"; + + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string MiddleName = "middle_name"; + /// /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims /// @@ -108,6 +128,11 @@ public struct JwtRegisteredClaimNames /// public const string NameId = "nameid"; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string Nickname = "nickname"; + /// /// https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest /// @@ -128,10 +153,25 @@ public struct JwtRegisteredClaimNames /// public const string PhoneNumberVerified = "phone_number_verified"; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string Picture = "picture"; + /// /// public const string Prn = "prn"; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string PreferredUsername = "preferred_username"; + + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string Profile = "profile"; + /// /// http://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout /// @@ -152,8 +192,19 @@ public struct JwtRegisteredClaimNames public const string UniqueName = "unique_name"; /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string UpdatedAt = "updated_at"; + + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims /// public const string Website = "website"; + + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string ZoneInfo = "zoneinfo"; } /// diff --git a/src/System.IdentityModel.Tokens.Jwt/JwtRegisteredClaimNames.cs b/src/System.IdentityModel.Tokens.Jwt/JwtRegisteredClaimNames.cs index bfdfda2d18..0669a04e14 100644 --- a/src/System.IdentityModel.Tokens.Jwt/JwtRegisteredClaimNames.cs +++ b/src/System.IdentityModel.Tokens.Jwt/JwtRegisteredClaimNames.cs @@ -7,9 +7,13 @@ namespace System.IdentityModel.Tokens.Jwt /// List of registered claims from different sources /// https://datatracker.ietf.org/doc/html/rfc7519#section-4 /// http://openid.net/specs/openid-connect-core-1_0.html#IDToken + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims /// public struct JwtRegisteredClaimNames { + + // Please keep in alphabetical order + /// /// public const string Actort = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Actort; @@ -24,6 +28,16 @@ public struct JwtRegisteredClaimNames /// public const string Amr = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Amr; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string Address = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Address; + + /// + /// http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken + /// + public const string AtHash = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.AtHash; + /// /// https://datatracker.ietf.org/doc/html/rfc7519#section-4 /// @@ -50,14 +64,14 @@ public struct JwtRegisteredClaimNames public const string CHash = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.CHash; /// - /// http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims /// - public const string AtHash = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.AtHash; + public const string Email = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Email; /// /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims /// - public const string Email = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Email; + public const string EmailVerified = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.EmailVerified; /// /// https://datatracker.ietf.org/doc/html/rfc7519#section-4 @@ -94,6 +108,16 @@ public struct JwtRegisteredClaimNames /// public const string Jti = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Jti; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string Locale = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Locale; + + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string MiddleName = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.MiddleName; + /// /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims /// @@ -103,6 +127,11 @@ public struct JwtRegisteredClaimNames /// public const string NameId = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.NameId; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string Nickname = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Nickname; + /// /// https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest /// @@ -113,10 +142,35 @@ public struct JwtRegisteredClaimNames /// public const string Nbf = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Nbf; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string PhoneNumber = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.PhoneNumber; + + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string PhoneNumberVerified = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.PhoneNumberVerified; + + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string Picture = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Picture; + /// /// public const string Prn = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Prn; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string PreferredUsername = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.PreferredUsername; + + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string Profile = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Profile; + /// /// http://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout /// @@ -136,8 +190,18 @@ public struct JwtRegisteredClaimNames /// public const string UniqueName = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.UniqueName; + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string UpdatedAt = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.UpdatedAt; + /// /// public const string Website = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Website; + + /// + /// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// + public const string ZoneInfo = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.ZoneInfo; } }