Skip to content

Commit

Permalink
Adding Missing Standard Claims (#2623)
Browse files Browse the repository at this point in the history
* Added missing standard claims.

* Clean-up

* Clean-up

* Addressing feedback

---------

Co-authored-by: Franco Fung <francofung@microsoft.com>
  • Loading branch information
FuPingFranco and Franco Fung authored Jun 7, 2024
1 parent dc15328 commit d104c98
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Licensed under the MIT License.

using System;
using System.Text;

namespace Microsoft.IdentityModel.JsonWebTokens
{
/// <summary>
/// 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
/// </summary>
public struct JwtRegisteredClaimNames
{
Expand All @@ -24,6 +24,11 @@ public struct JwtRegisteredClaimNames
/// </summary>
public const string Acr = "acr";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Address = "address";

/// <summary>
/// http://openid.net/specs/openid-connect-core-1_0.html#IDToken
/// </summary>
Expand Down Expand Up @@ -64,6 +69,11 @@ public struct JwtRegisteredClaimNames
/// </summary>
public const string Email = "email";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string EmailVerified = "email_verified";

/// <summary>
/// https://datatracker.ietf.org/doc/html/rfc7519#section-4
/// </summary>
Expand Down Expand Up @@ -99,6 +109,16 @@ public struct JwtRegisteredClaimNames
/// </summary>
public const string Jti = "jti";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Locale = "locale";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string MiddleName = "middle_name";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
Expand All @@ -108,6 +128,11 @@ public struct JwtRegisteredClaimNames
/// </summary>
public const string NameId = "nameid";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Nickname = "nickname";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
/// </summary>
Expand All @@ -128,10 +153,25 @@ public struct JwtRegisteredClaimNames
/// </summary>
public const string PhoneNumberVerified = "phone_number_verified";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Picture = "picture";

/// <summary>
/// </summary>
public const string Prn = "prn";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string PreferredUsername = "preferred_username";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Profile = "profile";

/// <summary>
/// http://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout
/// </summary>
Expand All @@ -152,8 +192,19 @@ public struct JwtRegisteredClaimNames
public const string UniqueName = "unique_name";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string UpdatedAt = "updated_at";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Website = "website";

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string ZoneInfo = "zoneinfo";
}

/// <summary>
Expand Down
70 changes: 67 additions & 3 deletions src/System.IdentityModel.Tokens.Jwt/JwtRegisteredClaimNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// </summary>
public struct JwtRegisteredClaimNames
{

// Please keep in alphabetical order

/// <summary>
/// </summary>
public const string Actort = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Actort;
Expand All @@ -24,6 +28,16 @@ public struct JwtRegisteredClaimNames
/// </summary>
public const string Amr = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Amr;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Address = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Address;

/// <summary>
/// http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken
/// </summary>
public const string AtHash = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.AtHash;

/// <summary>
/// https://datatracker.ietf.org/doc/html/rfc7519#section-4
/// </summary>
Expand All @@ -50,14 +64,14 @@ public struct JwtRegisteredClaimNames
public const string CHash = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.CHash;

/// <summary>
/// http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string AtHash = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.AtHash;
public const string Email = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Email;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Email = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Email;
public const string EmailVerified = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.EmailVerified;

/// <summary>
/// https://datatracker.ietf.org/doc/html/rfc7519#section-4
Expand Down Expand Up @@ -94,6 +108,16 @@ public struct JwtRegisteredClaimNames
/// </summary>
public const string Jti = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Jti;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Locale = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Locale;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string MiddleName = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.MiddleName;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
Expand All @@ -103,6 +127,11 @@ public struct JwtRegisteredClaimNames
/// </summary>
public const string NameId = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.NameId;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Nickname = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Nickname;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
/// </summary>
Expand All @@ -113,10 +142,35 @@ public struct JwtRegisteredClaimNames
/// </summary>
public const string Nbf = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Nbf;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string PhoneNumber = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.PhoneNumber;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string PhoneNumberVerified = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.PhoneNumberVerified;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Picture = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Picture;

/// <summary>
/// </summary>
public const string Prn = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Prn;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string PreferredUsername = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.PreferredUsername;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string Profile = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Profile;

/// <summary>
/// http://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout
/// </summary>
Expand All @@ -136,8 +190,18 @@ public struct JwtRegisteredClaimNames
/// </summary>
public const string UniqueName = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.UniqueName;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string UpdatedAt = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.UpdatedAt;

/// <summary>
/// </summary>
public const string Website = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Website;

/// <summary>
/// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
/// </summary>
public const string ZoneInfo = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.ZoneInfo;
}
}

0 comments on commit d104c98

Please sign in to comment.