Skip to content

Commit 014ef58

Browse files
Add Mixcloud provider (#569)
* Basic/initial Mixcloud support * Fixed tests * Update src/AspNet.Security.OAuth.Mixcloud/MixcloudAuthenticationExtensions.cs Co-authored-by: Martin Costello <[email protected]> * Update src/AspNet.Security.OAuth.Mixcloud/MixcloudAuthenticationHandler.cs Co-authored-by: Martin Costello <[email protected]> * Update src/AspNet.Security.OAuth.Mixcloud/MixcloudAuthenticationHandler.cs Co-authored-by: Martin Costello <[email protected]> * Update src/AspNet.Security.OAuth.Mixcloud/MixcloudAuthenticationOptions.cs Co-authored-by: Martin Costello <[email protected]> * Added biography tests and comments * Fixed formatting * Removed authors * Updated README with Mixcloud listing Co-authored-by: Martin Costello <[email protected]>
1 parent 0aeb2d9 commit 014ef58

10 files changed

+552
-0
lines changed

AspNet.Security.OAuth.Providers.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.WorkW
252252
EndProject
253253
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Notion", "src\AspNet.Security.OAuth.Notion\AspNet.Security.OAuth.Notion.csproj", "{DF2786DF-234D-4A8C-B166-0B8F8B7D527B}"
254254
EndProject
255+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Mixcloud", "src\AspNet.Security.OAuth.Mixcloud\AspNet.Security.OAuth.Mixcloud.csproj", "{7A2EC21F-D411-4B45-AA3B-70143C1A9E2F}"
256+
EndProject
255257
Global
256258
GlobalSection(SolutionConfigurationPlatforms) = preSolution
257259
Debug|Any CPU = Debug|Any CPU
@@ -566,6 +568,10 @@ Global
566568
{DF2786DF-234D-4A8C-B166-0B8F8B7D527B}.Debug|Any CPU.Build.0 = Debug|Any CPU
567569
{DF2786DF-234D-4A8C-B166-0B8F8B7D527B}.Release|Any CPU.ActiveCfg = Release|Any CPU
568570
{DF2786DF-234D-4A8C-B166-0B8F8B7D527B}.Release|Any CPU.Build.0 = Release|Any CPU
571+
{7A2EC21F-D411-4B45-AA3B-70143C1A9E2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
572+
{7A2EC21F-D411-4B45-AA3B-70143C1A9E2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
573+
{7A2EC21F-D411-4B45-AA3B-70143C1A9E2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
574+
{7A2EC21F-D411-4B45-AA3B-70143C1A9E2F}.Release|Any CPU.Build.0 = Release|Any CPU
569575
EndGlobalSection
570576
GlobalSection(SolutionProperties) = preSolution
571577
HideSolutionNode = FALSE
@@ -654,6 +660,7 @@ Global
654660
{01C2AC98-B615-49F8-80A5-475A2B75A8FD} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
655661
{C40ED377-E365-45FB-8B42-27BE82CC7BE3} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
656662
{DF2786DF-234D-4A8C-B166-0B8F8B7D527B} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
663+
{7A2EC21F-D411-4B45-AA3B-70143C1A9E2F} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
657664
EndGlobalSection
658665
GlobalSection(ExtensibilityGlobals) = postSolution
659666
SolutionGuid = {C7B54DE2-6407-4802-AD9C-CE54BF414C8C}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ If a provider you're looking for does not exist, consider making a PR to add one
151151
| LinkedIn | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.LinkedIn?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.LinkedIn/ "Download AspNet.Security.OAuth.LinkedIn from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.LinkedIn?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.LinkedIn "Download AspNet.Security.OAuth.LinkedIn from MyGet.org") | [Documentation](https://docs.microsoft.com/en-us/linkedin/shared/authentication/authentication "LinkedIn developer documentation") |
152152
| MailChimp | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.MailChimp?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.MailChimp/ "Download AspNet.Security.OAuth.MailChimp from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.MailChimp?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.MailChimp "Download AspNet.Security.OAuth.MailChimp from MyGet.org") | [Documentation](https://developer.mailchimp.com/documentation/mailchimp/guides/how-to-use-oauth2/ "MailChimp developer documentation") |
153153
| MailRu | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.MailRu?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.MailRu/ "Download AspNet.Security.OAuth.MailRu from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.MailRu?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.MailRu "Download AspNet.Security.OAuth.MailRu from MyGet.org") | [Documentation](https://o2.mail.ru/docs#web "MailRu developer documentation") |
154+
| Mixcloud | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Mixcloud?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Mixcloud/ "Download AspNet.Security.OAuth.Mixcloud from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Mixcloud?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Mixcloud "Download AspNet.Security.OAuth.Mixcloud from MyGet.org") | [Documentation](https://www.mixcloud.com/developers/#authorization "Mixcloud developer documentation") |
154155
| Moodle | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Moodle?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Moodle/ "Download AspNet.Security.OAuth.Moodle from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Moodle?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Moodle "Download AspNet.Security.OAuth.Moodle from MyGet.org") | [Documentation](https://github.com/HIT-ReFreSH/moodle-local_oauth "Moodle OAuth2 plugin developer documentation") |
155156
| Myob | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Myob?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Myob/ "Download AspNet.Security.OAuth.Myob from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Myob?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Myob "Download AspNet.Security.OAuth.Myob from MyGet.org") | [Documentation](https://developer.myob.com/api/accountright/api-overview/authentication/ "Myob developer documentation") |
156157
| NetEase | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.NetEase?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.NetEase/ "Download AspNet.Security.OAuth.NetEase from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.NetEase?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.NetEase "Download AspNet.Security.OAuth.NetEase from MyGet.org") | [Documentation](https://reg.163.com/help/help_oauth2.html "NetEase developer documentation") |
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net5.0</TargetFrameworks>
5+
</PropertyGroup>
6+
7+
<PropertyGroup>
8+
<Description>ASP.NET Core security middleware enabling Mixcloud authentication.</Description>
9+
<Authors>Michael DeMond</Authors>
10+
<PackageTags>aspnetcore;authentication;oauth;security;mixcloud</PackageTags>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
15+
<PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
16+
</ItemGroup>
17+
18+
</Project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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.Mixcloud
8+
{
9+
/// <summary>
10+
/// Contains constants specific to the <see cref="MixcloudAuthenticationHandler"/>.
11+
/// </summary>
12+
public static class MixcloudAuthenticationConstants
13+
{
14+
public static class Claims
15+
{
16+
public const string FullName = "urn:mixcloud:fullname";
17+
public const string ProfileUrl = "urn:mixcloud:profileurl";
18+
public const string City = "urn:mixcloud:city";
19+
public const string Biography = "urn:mixcloud:biography";
20+
public const string ProfileImageUrl = "urn:mixcloud:profileimageurl";
21+
public const string ProfileThumbnailUrl = "urn:mixcloud:profilethumbnailurl";
22+
}
23+
}
24+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
using Microsoft.AspNetCore.Authentication;
8+
using Microsoft.AspNetCore.Authentication.OAuth;
9+
10+
namespace AspNet.Security.OAuth.Mixcloud
11+
{
12+
/// <summary>
13+
/// Default values used by the Mixcloud authentication middleware.
14+
/// </summary>
15+
public static class MixcloudAuthenticationDefaults
16+
{
17+
/// <summary>
18+
/// Default value for <see cref="Microsoft.AspNetCore.Authentication.AuthenticationScheme.Name"/>.
19+
/// </summary>
20+
public const string AuthenticationScheme = "Mixcloud";
21+
22+
/// <summary>
23+
/// Default value for <see cref="Microsoft.AspNetCore.Authentication.AuthenticationScheme.DisplayName"/>.
24+
/// </summary>
25+
public const string DisplayName = "Mixcloud";
26+
27+
/// <summary>
28+
/// Default value for <see cref="AuthenticationSchemeOptions.ClaimsIssuer"/>.
29+
/// </summary>
30+
public const string Issuer = "Mixcloud";
31+
32+
/// <summary>
33+
/// Default value for <see cref="RemoteAuthenticationOptions.CallbackPath"/>.
34+
/// </summary>
35+
public const string CallbackPath = "/signin-mixcloud";
36+
37+
/// <summary>
38+
/// Default value for <see cref="OAuthOptions.AuthorizationEndpoint"/>.
39+
/// </summary>
40+
public const string AuthorizationEndpoint = "https://www.mixcloud.com/oauth/authorize";
41+
42+
/// <summary>
43+
/// Default value for <see cref="OAuthOptions.TokenEndpoint"/>.
44+
/// </summary>
45+
public const string TokenEndpoint = "https://www.mixcloud.com/oauth/access_token";
46+
47+
/// <summary>
48+
/// Default value for <see cref="OAuthOptions.UserInformationEndpoint"/>.
49+
/// </summary>
50+
public const string UserInformationEndpoint = "https://api.mixcloud.com/me";
51+
}
52+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
using System;
8+
using JetBrains.Annotations;
9+
using Microsoft.AspNetCore.Authentication;
10+
using Microsoft.Extensions.DependencyInjection;
11+
12+
namespace AspNet.Security.OAuth.Mixcloud
13+
{
14+
/// <summary>
15+
/// Extension methods to add Mixcloud authentication capabilities to an HTTP application pipeline.
16+
/// </summary>
17+
public static class MixcloudAuthenticationExtensions
18+
{
19+
/// <summary>
20+
/// Adds <see cref="MixcloudAuthenticationHandler"/> to the specified
21+
/// <see cref="AuthenticationBuilder"/>, which enables Mixcloud authentication capabilities.
22+
/// </summary>
23+
/// <param name="builder">The authentication builder.</param>
24+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
25+
public static AuthenticationBuilder AddMixcloud([NotNull] this AuthenticationBuilder builder)
26+
{
27+
return builder.AddMixcloud(MixcloudAuthenticationDefaults.AuthenticationScheme, _ => { });
28+
}
29+
30+
/// <summary>
31+
/// Adds <see cref="MixcloudAuthenticationHandler"/> to the specified
32+
/// <see cref="AuthenticationBuilder"/>, which enables Mixcloud authentication capabilities.
33+
/// </summary>
34+
/// <param name="builder">The authentication builder.</param>
35+
/// <param name="configuration">The delegate used to configure the OpenID 2.0 options.</param>
36+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
37+
public static AuthenticationBuilder AddMixcloud(
38+
[NotNull] this AuthenticationBuilder builder,
39+
[NotNull] Action<MixcloudAuthenticationOptions> configuration)
40+
{
41+
return builder.AddMixcloud(MixcloudAuthenticationDefaults.AuthenticationScheme, configuration);
42+
}
43+
44+
/// <summary>
45+
/// Adds <see cref="MixcloudAuthenticationHandler"/> to the specified
46+
/// <see cref="AuthenticationBuilder"/>, which enables Mixcloud authentication capabilities.
47+
/// </summary>
48+
/// <param name="builder">The authentication builder.</param>
49+
/// <param name="scheme">The authentication scheme associated with this instance.</param>
50+
/// <param name="configuration">The delegate used to configure the Mixcloud options.</param>
51+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
52+
public static AuthenticationBuilder AddMixcloud(
53+
[NotNull] this AuthenticationBuilder builder,
54+
[NotNull] string scheme,
55+
[NotNull] Action<MixcloudAuthenticationOptions> configuration)
56+
{
57+
return builder.AddMixcloud(scheme, MixcloudAuthenticationDefaults.DisplayName, configuration);
58+
}
59+
60+
/// <summary>
61+
/// Adds <see cref="MixcloudAuthenticationHandler"/> to the specified
62+
/// <see cref="AuthenticationBuilder"/>, which enables Mixcloud authentication capabilities.
63+
/// </summary>
64+
/// <param name="builder">The authentication builder.</param>
65+
/// <param name="scheme">The authentication scheme associated with this instance.</param>
66+
/// <param name="caption">The optional display name associated with this instance.</param>
67+
/// <param name="configuration">The delegate used to configure the Mixcloud options.</param>
68+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
69+
public static AuthenticationBuilder AddMixcloud(
70+
[NotNull] this AuthenticationBuilder builder,
71+
[NotNull] string scheme,
72+
[CanBeNull] string caption,
73+
[NotNull] Action<MixcloudAuthenticationOptions> configuration)
74+
{
75+
return builder.AddOAuth<MixcloudAuthenticationOptions, MixcloudAuthenticationHandler>(scheme, caption, configuration);
76+
}
77+
}
78+
}

0 commit comments

Comments
 (0)