Skip to content

Commit eca3ad4

Browse files
Add Ebay provider (#603)
* Added support to Ebay identities * Rename challenge callback name * Respect brand Co-authored-by: Martin Costello <[email protected]> * Respect brand Co-authored-by: Martin Costello <[email protected]> * Respect brand Co-authored-by: Martin Costello <[email protected]> * Use default framework Co-authored-by: Martin Costello <[email protected]> * Remove unnecessary include Co-authored-by: Martin Costello <[email protected]> * Respect brand Co-authored-by: Martin Costello <[email protected]> * Remove unnecessary package version declaration Co-authored-by: Martin Costello <[email protected]> * Prefer fields instead of consts Co-authored-by: Martin Costello <[email protected]> * Add default values doc header Co-authored-by: Martin Costello <[email protected]> * Respect brand Co-authored-by: Martin Costello <[email protected]> * Respect brand Co-authored-by: Martin Costello <[email protected]> * Respect brand Co-authored-by: Martin Costello <[email protected]> * Respect brand Co-authored-by: Martin Costello <[email protected]> * Respect brand Co-authored-by: Martin Costello <[email protected]> * Initialize ticket correctly Co-authored-by: Martin Costello <[email protected]> * Code clean-up * Use options Co-authored-by: Martin Costello <[email protected]> * Fix syntax error Co-authored-by: Martin Costello <[email protected]> * Validate options * Use correct provider scope names. Added schema to RuName on test option initialization. * Correct the property type on provider doc * Remove unused using. Rollback auth schema to const. Co-authored-by: Martin Costello <[email protected]>
1 parent e283dca commit eca3ad4

File tree

11 files changed

+434
-0
lines changed

11 files changed

+434
-0
lines changed

AspNet.Security.OAuth.Providers.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Zende
261261
EndProject
262262
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.QuickBooks", "src\AspNet.Security.OAuth.QuickBooks\AspNet.Security.OAuth.QuickBooks.csproj", "{815DA59A-E884-4BAD-B16C-D0B550B40A8D}"
263263
EndProject
264+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Security.OAuth.Ebay", "src\AspNet.Security.OAuth.Ebay\AspNet.Security.OAuth.Ebay.csproj", "{574A52D9-E7A5-4E11-8F36-5C8AA7033287}"
265+
EndProject
264266
Global
265267
GlobalSection(SolutionConfigurationPlatforms) = preSolution
266268
Debug|Any CPU = Debug|Any CPU
@@ -591,6 +593,10 @@ Global
591593
{815DA59A-E884-4BAD-B16C-D0B550B40A8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
592594
{815DA59A-E884-4BAD-B16C-D0B550B40A8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
593595
{815DA59A-E884-4BAD-B16C-D0B550B40A8D}.Release|Any CPU.Build.0 = Release|Any CPU
596+
{574A52D9-E7A5-4E11-8F36-5C8AA7033287}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
597+
{574A52D9-E7A5-4E11-8F36-5C8AA7033287}.Debug|Any CPU.Build.0 = Debug|Any CPU
598+
{574A52D9-E7A5-4E11-8F36-5C8AA7033287}.Release|Any CPU.ActiveCfg = Release|Any CPU
599+
{574A52D9-E7A5-4E11-8F36-5C8AA7033287}.Release|Any CPU.Build.0 = Release|Any CPU
594600
EndGlobalSection
595601
GlobalSection(SolutionProperties) = preSolution
596602
HideSolutionNode = FALSE
@@ -683,6 +689,7 @@ Global
683689
{91BB9A49-9C88-4132-96E4-2D6148ACDE77} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
684690
{C90BA18B-E6C4-4E84-AFCC-58A4EE13BA40} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
685691
{815DA59A-E884-4BAD-B16C-D0B550B40A8D} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
692+
{574A52D9-E7A5-4E11-8F36-5C8AA7033287} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
686693
EndGlobalSection
687694
GlobalSection(ExtensibilityGlobals) = postSolution
688695
SolutionGuid = {C7B54DE2-6407-4802-AD9C-CE54BF414C8C}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ If a provider you're looking for does not exist, consider making a PR to add one
135135
| Deezer | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Deezer?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Deezer/ "Download AspNet.Security.OAuth.Deezer from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Deezer?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Deezer "Download AspNet.Security.OAuth.Deezer from MyGet.org") | [Documentation](https://developers.deezer.com/api/oauth "Deezer developer documentation") |
136136
| Discord | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Discord?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Discord/ "Download AspNet.Security.OAuth.Discord from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Discord?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Discord "Download AspNet.Security.OAuth.Discord from MyGet.org") | [Documentation](https://discord.com/developers/docs/topics/oauth2 "Discord developer documentation") |
137137
| Dropbox | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Dropbox?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Dropbox/ "Download AspNet.Security.OAuth.Dropbox from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Dropbox?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Dropbox "Download AspNet.Security.OAuth.Dropbox from MyGet.org") | [Documentation](https://www.dropbox.com/developers/reference/oauth-guide?_tk=guides_lp&_ad=deepdive2&_camp=oauth "Dropbox developer documentation") |
138+
| eBay | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Ebay?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Ebay/ "Download AspNet.Security.OAuth.Ebay from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Ebay?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Ebay "Download AspNet.Security.OAuth.Ebay from MyGet.org") | [Documentation](https://developer.ebay.com/api-docs/static/oauth-tokens.html "eBay developer documentation") |
138139
| EVEOnline | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.EVEOnline?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.EVEOnline/ "Download AspNet.Security.OAuth.EVEOnline from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.EVEOnline?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.EVEOnline "Download AspNet.Security.OAuth.EVEOnline from MyGet.org") | [Documentation](https://github.com/esi/esi-docs/blob/master/docs/sso/web_based_sso_flow.md "EVEOnline developer documentation") |
139140
| ExactOnline | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.ExactOnline?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.ExactOnline/ "Download AspNet.Security.OAuth.ExactOnline from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.ExactOnline?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.ExactOnline "Download AspNet.Security.OAuth.ExactOnline from MyGet.org") | [Documentation](https://support.exactonline.com/community/s/knowledge-base#All-All-DNO-Content-gettingstarted "ExactOnline developer documentation") |
140141
| Fitbit | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Fitbit?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Fitbit/ "Download AspNet.Security.OAuth.Fitbit from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Fitbit?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Fitbit "Download AspNet.Security.OAuth.Fitbit from MyGet.org") | [Documentation](https://dev.fitbit.com/build/reference/web-api/oauth2/ "Fitbit developer documentation") |

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ covered by the section above.
4747
| BattleNet | **Required** | [Documentation](battlenet.md "BattleNet provider documentation") |
4848
| Bitbucket | _Optional_ | [Documentation](bitbucket.md "Bitbucket provider documentation") |
4949
| Discord | _Optional_ | [Documentation](discord.md "Discord provider documentation") |
50+
| eBay | **Required** | [Documentation](ebay.md "eBay provider documentation") |
5051
| EVEOnline | _Optional_ | [Documentation](eveonline.md "EVEOnline provider documentation") |
5152
| Foursquare | _Optional_ | [Documentation](foursquare.md "Foursquare provider documentation") |
5253
| GitHub | _Optional_ | [Documentation](github.md "GitHub provider documentation") |

docs/ebay.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Integrating the eBay Provider
2+
3+
## Example
4+
5+
```csharp
6+
services.AddAuthentication(options => /* Auth configuration */)
7+
.AddEbay(options =>
8+
{
9+
options.ClientId = "my-client-id";
10+
options.ClientSecret = "my-client-secret";
11+
options.RuName = "my-ru-name";
12+
});
13+
```
14+
15+
## Required Additional Settings
16+
17+
| Property Name | Property Type | Description | Default Value |
18+
| :------------ | :------------ | :----------------------------------------------------------- | :------------ |
19+
| `RuName` | `string` | Sets the `redirect_uri` parameter that the service uses for authorization, as well as a URL to redirect the user to after they've complete the permissions grant request. Instead of a URL, the eBay services require a custom *RuName* value that eBay generates and assigns to your application. For further info see also the official [documentation](https://developer.ebay.com/api-docs/static/oauth-redirect-uri.html). | `default!` |
20+
21+
## Optional Settings
22+
23+
None.
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>$(DefaultNetCoreTargetFramework)</TargetFrameworks>
5+
</PropertyGroup>
6+
7+
<PropertyGroup>
8+
<Description>ASP.NET Core security middleware enabling eBay authentication.</Description>
9+
<Authors>Nicola Biancolini</Authors>
10+
<PackageTags>ebay;aspnetcore;authentication;oauth;security</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: 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.Ebay
11+
{
12+
/// <summary>
13+
/// Default values used by the eBay authentication provider.
14+
/// </summary>
15+
public static class EbayAuthenticationDefaults
16+
{
17+
/// <summary>
18+
/// Default value for <see cref="AuthenticationScheme.Name"/>.
19+
/// </summary>
20+
public const string AuthenticationScheme = "Ebay";
21+
22+
/// <summary>
23+
/// Default value for <see cref="AuthenticationScheme.DisplayName"/>.
24+
/// </summary>
25+
public static readonly string DisplayName = "eBay";
26+
27+
/// <summary>
28+
/// Default value for <see cref="AuthenticationSchemeOptions.ClaimsIssuer"/>.
29+
/// </summary>
30+
public static readonly string Issuer = "Ebay";
31+
32+
/// <summary>
33+
/// Default value for <see cref="RemoteAuthenticationOptions.CallbackPath"/>.
34+
/// </summary>
35+
public static readonly string CallbackPath = "/signin-ebay";
36+
37+
/// <summary>
38+
/// Default value for <see cref="OAuthOptions.AuthorizationEndpoint"/>.
39+
/// </summary>
40+
public static readonly string AuthorizationEndpoint = "https://auth.ebay.com/oauth2/authorize";
41+
42+
/// <summary>
43+
/// Default value for <see cref="OAuthOptions.TokenEndpoint"/>.
44+
/// </summary>
45+
public static readonly string TokenEndpoint = "https://api.ebay.com/identity/v1/oauth2/token";
46+
47+
/// <summary>
48+
/// Default value for <see cref="OAuthOptions.UserInformationEndpoint"/>.
49+
/// </summary>
50+
public static readonly string UserInformationEndpoint = "https://apiz.ebay.com/commerce/identity/v1/user";
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 AspNet.Security.OAuth.Ebay;
9+
using JetBrains.Annotations;
10+
using Microsoft.AspNetCore.Authentication;
11+
12+
namespace Microsoft.Extensions.DependencyInjection
13+
{
14+
/// <summary>
15+
/// Extension methods to add eBay authentication capabilities to an HTTP application pipeline.
16+
/// </summary>
17+
public static class EbayAuthenticationExtensions
18+
{
19+
/// <summary>
20+
/// Adds <see cref="EbayAuthenticationHandler"/> to the specified
21+
/// <see cref="AuthenticationBuilder"/>, which enables eBay authentication capabilities.
22+
/// </summary>
23+
/// <param name="builder">The authentication builder.</param>
24+
/// <returns>A reference to this instance after the operation has completed.</returns>
25+
public static AuthenticationBuilder AddEbay([NotNull] this AuthenticationBuilder builder)
26+
{
27+
return builder.AddEbay(EbayAuthenticationDefaults.AuthenticationScheme, options => { });
28+
}
29+
30+
/// <summary>
31+
/// Adds <see cref="EbayAuthenticationHandler"/> to the specified
32+
/// <see cref="AuthenticationBuilder"/>, which enables eBay 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>A reference to this instance after the operation has completed.</returns>
37+
public static AuthenticationBuilder AddEbay(
38+
[NotNull] this AuthenticationBuilder builder,
39+
[NotNull] Action<EbayAuthenticationOptions> configuration)
40+
{
41+
return builder.AddEbay(EbayAuthenticationDefaults.AuthenticationScheme, configuration);
42+
}
43+
44+
/// <summary>
45+
/// Adds <see cref="EbayAuthenticationHandler"/> to the specified
46+
/// <see cref="AuthenticationBuilder"/>, which enables eBay 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 eBay options.</param>
51+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
52+
public static AuthenticationBuilder AddEbay(
53+
[NotNull] this AuthenticationBuilder builder,
54+
[NotNull] string scheme,
55+
[NotNull] Action<EbayAuthenticationOptions> configuration)
56+
{
57+
return builder.AddEbay(scheme, EbayAuthenticationDefaults.DisplayName, configuration);
58+
}
59+
60+
/// <summary>
61+
/// Adds <see cref="EbayAuthenticationHandler"/> to the specified
62+
/// <see cref="AuthenticationBuilder"/>, which enables eBay 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 eBay options.</param>
68+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
69+
public static AuthenticationBuilder AddEbay(
70+
[NotNull] this AuthenticationBuilder builder,
71+
[NotNull] string scheme,
72+
[CanBeNull] string caption,
73+
[NotNull] Action<EbayAuthenticationOptions> configuration)
74+
{
75+
return builder.AddOAuth<EbayAuthenticationOptions, EbayAuthenticationHandler>(scheme, caption, configuration);
76+
}
77+
}
78+
}

0 commit comments

Comments
 (0)