Skip to content

Commit f3fc9c0

Browse files
committed
Introduce new claims constants classes
1 parent d58f855 commit f3fc9c0

File tree

51 files changed

+788
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+788
-99
lines changed

src/AspNet.Security.OAuth.Autodesk/AutodeskAuthenticationConstants.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,14 @@
77
namespace AspNet.Security.OAuth.Autodesk
88
{
99
/// <summary>
10-
/// Constants used by the Autodesk authentication middleware.
10+
/// Contains constants specific to the <see cref="AutodeskAuthenticationHandler"/>.
1111
/// </summary>
1212
public static class AutodeskAuthenticationConstants
1313
{
1414
public static class Claims
1515
{
16-
/// <summary>
17-
/// Name of the claim containing a boolean value indicating
18-
/// whether the user's email has been verified.
19-
/// </summary>
2016
public const string EmailVerified = "urn:autodesk:emailverified";
21-
22-
/// <summary>
23-
/// Name of the claim containing a boolean value indicating
24-
/// whether the user has enabled two factor authentication.
25-
/// </summary>
2617
public const string TwoFactorEnabled = "urn:autodesk:twofactorenabled";
2718
}
28-
29-
public static class Scopes
30-
{
31-
/// <summary>
32-
/// Name of the OAuth2 scope used for reading Autodesk user profile.
33-
/// </summary>
34-
public const string UserProfileRead = "user-profile:read";
35-
}
3619
}
3720
}

src/AspNet.Security.OAuth.Autodesk/AutodeskAuthenticationOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public AutodeskAuthenticationOptions()
2626
TokenEndpoint = AutodeskAuthenticationDefaults.TokenEndpoint;
2727
UserInformationEndpoint = AutodeskAuthenticationDefaults.UserInformationEndpoint;
2828

29-
Scope.Add(AutodeskAuthenticationConstants.Scopes.UserProfileRead);
29+
Scope.Add("user-profile:read");
3030
}
3131
}
3232
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
3+
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
4+
* for more information concerning the license and the contributors participating to this project.
5+
*/
6+
7+
namespace AspNet.Security.OAuth.Bitbucket
8+
{
9+
/// <summary>
10+
/// Contains constants specific to the <see cref="BitbucketAuthenticationHandler"/>.
11+
/// </summary>
12+
public static class BitbucketAuthenticationConstants
13+
{
14+
public static class Claims
15+
{
16+
public const string DisplayName = "urn:bitbucket:name";
17+
public const string Website = "urn:bitbucket:url";
18+
}
19+
}
20+
}

src/AspNet.Security.OAuth.Bitbucket/BitbucketAuthenticationHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.AspNetCore.Http.Authentication;
1616
using Microsoft.Extensions.Logging;
1717
using Newtonsoft.Json.Linq;
18+
using static AspNet.Security.OAuth.Bitbucket.BitbucketAuthenticationConstants;
1819

1920
namespace AspNet.Security.OAuth.Bitbucket
2021
{
@@ -49,8 +50,8 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync([NotNull]
4950
identity.AddOptionalClaim(ClaimTypes.NameIdentifier, BitbucketAuthenticationHelper.GetIdentifier(payload), Options.ClaimsIssuer)
5051
.AddOptionalClaim(ClaimTypes.Name, BitbucketAuthenticationHelper.GetLogin(payload), Options.ClaimsIssuer)
5152
.AddOptionalClaim(ClaimTypes.Email, BitbucketAuthenticationHelper.GetEmail(payload), Options.ClaimsIssuer)
52-
.AddOptionalClaim("urn:bitbucket:name", BitbucketAuthenticationHelper.GetName(payload), Options.ClaimsIssuer)
53-
.AddOptionalClaim("urn:bitbucket:url", BitbucketAuthenticationHelper.GetLink(payload), Options.ClaimsIssuer);
53+
.AddOptionalClaim(Claims.DisplayName, BitbucketAuthenticationHelper.GetName(payload), Options.ClaimsIssuer)
54+
.AddOptionalClaim(Claims.Website, BitbucketAuthenticationHelper.GetLink(payload), Options.ClaimsIssuer);
5455

5556
// When the email address is not public, retrieve it from
5657
// the emails endpoint if the user:email scope is specified.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
3+
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
4+
* for more information concerning the license and the contributors participating to this project.
5+
*/
6+
7+
namespace AspNet.Security.OAuth.DeviantArt
8+
{
9+
/// <summary>
10+
/// Contains constants specific to the <see cref="DeviantArtAuthenticationHandler"/>.
11+
/// </summary>
12+
public static class DeviantArtAuthenticationConstants
13+
{
14+
public static class Claims
15+
{
16+
public const string Username = "urn:deviantart:name";
17+
}
18+
}
19+
}

src/AspNet.Security.OAuth.DeviantArt/DeviantArtAuthenticationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.AspNetCore.Http.Authentication;
1616
using Microsoft.Extensions.Logging;
1717
using Newtonsoft.Json.Linq;
18+
using static AspNet.Security.OAuth.DeviantArt.DeviantArtAuthenticationConstants;
1819

1920
namespace AspNet.Security.OAuth.DeviantArt
2021
{
@@ -48,7 +49,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync([NotNull]
4849

4950
identity.AddOptionalClaim(ClaimTypes.NameIdentifier, DeviantArtAuthenticationHelper.GetIdentifier(payload), Options.ClaimsIssuer)
5051
.AddOptionalClaim(ClaimTypes.Name, DeviantArtAuthenticationHelper.GetLogin(payload), Options.ClaimsIssuer)
51-
.AddOptionalClaim("urn:DeviantArt:name", DeviantArtAuthenticationHelper.GetName(payload), Options.ClaimsIssuer);
52+
.AddOptionalClaim(Claims.Username, DeviantArtAuthenticationHelper.GetName(payload), Options.ClaimsIssuer);
5253

5354
var principal = new ClaimsPrincipal(identity);
5455
var ticket = new AuthenticationTicket(principal, properties, Options.AuthenticationScheme);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
3+
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
4+
* for more information concerning the license and the contributors participating to this project.
5+
*/
6+
7+
namespace AspNet.Security.OAuth.EVEOnline
8+
{
9+
/// <summary>
10+
/// Contains constants specific to the <see cref="EVEOnlineAuthenticationHandler"/>.
11+
/// </summary>
12+
public static class EVEOnlineAuthenticationConstants
13+
{
14+
public static class Claims
15+
{
16+
public const string Scopes = "urn:eveonline:scopes";
17+
}
18+
}
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
3+
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
4+
* for more information concerning the license and the contributors participating to this project.
5+
*/
6+
7+
namespace AspNet.Security.OAuth.Fitbit
8+
{
9+
/// <summary>
10+
/// Contains constants specific to the <see cref="FitbitAuthenticationHandler"/>.
11+
/// </summary>
12+
public static class FitbitAuthenticationConstants
13+
{
14+
public static class Claims
15+
{
16+
public const string Avatar = "urn:fitbit:avatar";
17+
public const string Avatar150 = "urn:fitbit:avatar150";
18+
}
19+
}
20+
}

src/AspNet.Security.OAuth.Fitbit/FitbitAuthenticationHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Microsoft.AspNetCore.Http.Authentication;
1919
using Microsoft.Extensions.Logging;
2020
using Newtonsoft.Json.Linq;
21+
using static AspNet.Security.OAuth.Fitbit.FitbitAuthenticationConstants;
2122

2223
namespace AspNet.Security.OAuth.Fitbit
2324
{
@@ -51,8 +52,8 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync([NotNull]
5152

5253
identity.AddOptionalClaim(ClaimTypes.NameIdentifier, FitbitAuthenticationHelper.GetIdentifier(payload), Options.ClaimsIssuer)
5354
.AddOptionalClaim(ClaimTypes.Name, FitbitAuthenticationHelper.GetLogin(payload), Options.ClaimsIssuer)
54-
.AddOptionalClaim("urn:fitbit:avatar", FitbitAuthenticationHelper.GetAvatar(payload), Options.ClaimsIssuer)
55-
.AddOptionalClaim("urn:fitbit:avatar150", FitbitAuthenticationHelper.GetAvatar150(payload), Options.ClaimsIssuer);
55+
.AddOptionalClaim(Claims.Avatar, FitbitAuthenticationHelper.GetAvatar(payload), Options.ClaimsIssuer)
56+
.AddOptionalClaim(Claims.Avatar150, FitbitAuthenticationHelper.GetAvatar150(payload), Options.ClaimsIssuer);
5657

5758
var principal = new ClaimsPrincipal(identity);
5859
var ticket = new AuthenticationTicket(principal, properties, Options.AuthenticationScheme);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
3+
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
4+
* for more information concerning the license and the contributors participating to this project.
5+
*/
6+
7+
namespace AspNet.Security.OAuth.GitHub
8+
{
9+
/// <summary>
10+
/// Contains constants specific to the <see cref="GitHubAuthenticationHandler"/>.
11+
/// </summary>
12+
public static class GitHubAuthenticationConstants
13+
{
14+
public static class Claims
15+
{
16+
public const string Name = "urn:github:name";
17+
public const string Url = "urn:github:url";
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)