Skip to content

Commit b235a6c

Browse files
Add Line provider (#524)
* Add Line provider. * Add the unit testing & the settings documentation for Line * Update the target framework of Line provider to net5.0 Co-authored-by: Martin Costello <[email protected]>
1 parent bb7878a commit b235a6c

12 files changed

+485
-0
lines changed

AspNet.Security.OAuth.Providers.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.AmoCr
208208
EndProject
209209
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Alipay", "src\AspNet.Security.OAuth.Alipay\AspNet.Security.OAuth.Alipay.csproj", "{61AB67B0-0F4A-47A2-A4D8-9738AA34C468}"
210210
EndProject
211+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Security.OAuth.Line", "src\AspNet.Security.OAuth.Line\AspNet.Security.OAuth.Line.csproj", "{6A2FEBAB-2372-4043-BD37-B2E94887BA9B}"
212+
EndProject
211213
Global
212214
GlobalSection(SolutionConfigurationPlatforms) = preSolution
213215
Debug|Any CPU = Debug|Any CPU
@@ -490,6 +492,10 @@ Global
490492
{DDF7546B-51C4-46EB-B102-7EE720E8E74F}.Debug|Any CPU.Build.0 = Debug|Any CPU
491493
{DDF7546B-51C4-46EB-B102-7EE720E8E74F}.Release|Any CPU.ActiveCfg = Release|Any CPU
492494
{DDF7546B-51C4-46EB-B102-7EE720E8E74F}.Release|Any CPU.Build.0 = Release|Any CPU
495+
{6A2FEBAB-2372-4043-BD37-B2E94887BA9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
496+
{6A2FEBAB-2372-4043-BD37-B2E94887BA9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
497+
{6A2FEBAB-2372-4043-BD37-B2E94887BA9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
498+
{6A2FEBAB-2372-4043-BD37-B2E94887BA9B}.Release|Any CPU.Build.0 = Release|Any CPU
493499
{61AB67B0-0F4A-47A2-A4D8-9738AA34C468}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
494500
{61AB67B0-0F4A-47A2-A4D8-9738AA34C468}.Debug|Any CPU.Build.0 = Debug|Any CPU
495501
{61AB67B0-0F4A-47A2-A4D8-9738AA34C468}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -574,6 +580,7 @@ Global
574580
{1B19314C-9F33-4E71-AF0C-46ED8AB621CE} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
575581
{26DDE1D4-45D5-4CAA-ACB6-71FECF781B27} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
576582
{DDF7546B-51C4-46EB-B102-7EE720E8E74F} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
583+
{6A2FEBAB-2372-4043-BD37-B2E94887BA9B} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
577584
{61AB67B0-0F4A-47A2-A4D8-9738AA34C468} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
578585
EndGlobalSection
579586
GlobalSection(ExtensibilityGlobals) = postSolution

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ We would love it if you could help contributing to this repository.
5252
* [Andrii Chebukin](https://github.com/xperiandri)
5353
* [Anthony Yates](https://github.com/AnthonyYates)
5454
* [Chino Chang](https://github.com/kinosang)
55+
* [CoCo Lin](https://github.com/linmasaki)
5556
* [Dave Timmins](https://github.com/davetimmins)
5657
* [Dmitry Popov](https://github.com/justdmitry)
5758
* [Eric Green](https://github.com/ericgreenmix)
@@ -145,6 +146,7 @@ If a provider you're looking for does not exist, consider making a PR to add one
145146
| KakaoTalk | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.KakaoTalk?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.KakaoTalk/ "Download AspNet.Security.OAuth.KakaoTalk from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.KakaoTalk?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.KakaoTalk "Download AspNet.Security.OAuth.KakaoTalk from MyGet.org") | [Documentation](https://developers.kakao.com/docs/latest/en/kakaologin/common "KakaoTalk developer documentation") |
146147
| Kloudless | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Kloudless?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Kloudless/ "Download AspNet.Security.OAuth.Kloudless from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Kloudless?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Kloudless "Download AspNet.Security.OAuth.Kloudless from MyGet.org") | [Documentation](https://developers.kloudless.com/docs/v1/authentication "Kloudless developer documentation") |
147148
| Lichess | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Lichess?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Lichess/ "Download AspNet.Security.OAuth.Lichess from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Lichess?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Lichess "Download AspNet.Security.OAuth.Lichess from MyGet.org") | [Documentation](https://lichess.org/api#section/Authentication "Lichess developer documentation") |
149+
| Line | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Line?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Line/ "Download AspNet.Security.OAuth.Line from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Line?includePreReleases=false)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Line "Download AspNet.Security.OAuth.Line from MyGet.org") | [Documentation](https://developers.line.biz/en/docs/line-login/integrate-line-login "Line developer documentation") |
148150
| 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") |
149151
| 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") |
150152
| 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") |

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ covered by the section above.
5353
| Gitee | _Optional_ | [Documentation](gitee.md "Gitee provider documentation") |
5454
| Instagram | _Optional_ | [Documentation](instagram.md "Instagram provider documentation") |
5555
| Kloudless | _Optional_ | [Documentation](kloudless.md "Kloudless provider documentation") |
56+
| Line | _Optional_ | [Documentation](line.md "Line provider documentation") |
5657
| LinkedIn | _Optional_ | [Documentation](linkedin.md "LinkedIn provider documentation") |
5758
| Odnoklassniki | _Optional_ | [Documentation](odnoklassniki.md "Odnoklassniki provider documentation") |
5859
| Okta | **Required** | [Documentation](okta.md "Okta provider documentation") |

docs/line.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Integrating the Line Provider
2+
3+
## Example
4+
5+
```csharp
6+
services.AddAuthentication(options => /* Auth configuration */)
7+
.AddLine(options =>
8+
{
9+
options.ClientId = "my-channel-id";
10+
options.ClientSecret = "my-channel-secret";
11+
});
12+
```
13+
14+
## Required Additional Settings
15+
16+
_None._
17+
18+
## Optional Settings
19+
20+
| Property Name | Property Type | Description | Default Value |
21+
|:--|:--|:--|:--|
22+
| `Prompt` | `bool` | Used to force the consent screen to be displayed even if the user has already granted all requested permissions. | `false` |
23+
| `UserEmailsEndpoint` | `string` | The address of the endpoint exposing the email addresses associated with the logged in user. | `LineAuthenticationDefaults.UserEmailsEndpoint` |
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 Line authentication.</Description>
9+
<Authors>CoCo Lin</Authors>
10+
<PackageTags>aspnetcore;authentication;line;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: 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.Line
8+
{
9+
/// <summary>
10+
/// Contains constants specific to the <see cref="LineAuthenticationHandler"/>.
11+
/// </summary>
12+
public static class LineAuthenticationConstants
13+
{
14+
public static class Claims
15+
{
16+
public const string PictureUrl = "urn:line:picture_url";
17+
}
18+
}
19+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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.Line
11+
{
12+
/// <summary>
13+
/// Default values for Line authentication.
14+
/// </summary>
15+
public static class LineAuthenticationDefaults
16+
{
17+
public const string AuthenticationScheme = "Line";
18+
19+
public const string DisplayName = "Line";
20+
21+
/// <summary>
22+
/// Default value for <see cref="RemoteAuthenticationOptions.CallbackPath"/>.
23+
/// </summary>
24+
public const string CallbackPath = "/signin-line";
25+
26+
/// <summary>
27+
/// Default value for <see cref="AuthenticationSchemeOptions.ClaimsIssuer"/>.
28+
/// </summary>
29+
public const string Issuer = "Line";
30+
31+
/// <summary>
32+
/// Default value for <see cref="OAuthOptions.AuthorizationEndpoint"/>.
33+
/// </summary>
34+
public const string AuthorizationEndpoint = "https://access.line.me/oauth2/v2.1/authorize";
35+
36+
/// <summary>
37+
/// Default value for <see cref="OAuthOptions.TokenEndpoint"/>.
38+
/// </summary>
39+
public const string TokenEndpoint = "https://api.line.me/oauth2/v2.1/token";
40+
41+
/// <summary>
42+
/// Default value for <see cref="OAuthOptions.UserInformationEndpoint"/>.
43+
/// </summary>
44+
public const string UserInformationEndpoint = "https://api.line.me/v2/profile";
45+
46+
/// <summary>
47+
/// Default value for <see cref="LineAuthenticationOptions.UserEmailsEndpoint"/>.
48+
/// </summary>
49+
public const string UserEmailsEndpoint = "https://api.line.me/oauth2/v2.1/verify";
50+
}
51+
}
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.Line;
9+
using JetBrains.Annotations;
10+
using Microsoft.AspNetCore.Authentication;
11+
12+
namespace Microsoft.Extensions.DependencyInjection
13+
{
14+
/// <summary>
15+
/// Extension methods to add Line authentication capabilities to an HTTP application pipeline.
16+
/// </summary>
17+
public static class LineAuthenticationExtensions
18+
{
19+
/// <summary>
20+
/// Adds <see cref="LineAuthenticationHandler"/> to the specified
21+
/// <see cref="AuthenticationBuilder"/>, which enables Line 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 AddLine([NotNull] this AuthenticationBuilder builder)
26+
{
27+
return builder.AddLine(LineAuthenticationDefaults.AuthenticationScheme, options => { });
28+
}
29+
30+
/// <summary>
31+
/// Adds <see cref="LineAuthenticationHandler"/> to the specified
32+
/// <see cref="AuthenticationBuilder"/>, which enables Line 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 AddLine(
38+
[NotNull] this AuthenticationBuilder builder,
39+
[NotNull] Action<LineAuthenticationOptions> configuration)
40+
{
41+
return builder.AddLine(LineAuthenticationDefaults.AuthenticationScheme, configuration);
42+
}
43+
44+
/// <summary>
45+
/// Adds <see cref="LineAuthenticationHandler"/> to the specified
46+
/// <see cref="AuthenticationBuilder"/>, which enables Line 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 Line options.</param>
51+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
52+
public static AuthenticationBuilder AddLine(
53+
[NotNull] this AuthenticationBuilder builder,
54+
[NotNull] string scheme,
55+
[NotNull] Action<LineAuthenticationOptions> configuration)
56+
{
57+
return builder.AddLine(scheme, LineAuthenticationDefaults.DisplayName, configuration);
58+
}
59+
60+
/// <summary>
61+
/// Adds <see cref="LineAuthenticationHandler"/> to the specified
62+
/// <see cref="AuthenticationBuilder"/>, which enables Line 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 Line options.</param>
68+
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
69+
public static AuthenticationBuilder AddLine(
70+
[NotNull] this AuthenticationBuilder builder,
71+
[NotNull] string scheme,
72+
[CanBeNull] string caption,
73+
[NotNull] Action<LineAuthenticationOptions> configuration)
74+
{
75+
return builder.AddOAuth<LineAuthenticationOptions, LineAuthenticationHandler>(scheme, caption, configuration);
76+
}
77+
}
78+
}

0 commit comments

Comments
 (0)