-
Notifications
You must be signed in to change notification settings - Fork 551
Increase support for authorization of Wechat Webpage #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
83213dd
Introduce a force_verify option in the Twitch provider
zAfLu 05536cf
Merge branch 'dev' of https://github.com/saber-wang/AspNet.Security.O…
saber-wang ecf0e60
Merge branch 'dev' of https://github.com/saber-wang/AspNet.Security.O…
saber-wang d2933d8
Merge branch 'dev' of https://github.com/saber-wang/AspNet.Security.O…
saber-wang de50069
Store state in redirectUri when authorizing Wechat Web pages to preve…
saber-wang ba6e81c
Optimization code
saber-wang 17fd49d
Use TryGetValue()
saber-wang fa0298d
Merge pull request #1 from aspnet-contrib/dev
saber-wang 7891b25
add WechatTests
saber-wang 53320b1
Revert "add WechatTests"
saber-wang 7ba0fc6
Revert "Revert "add WechatTests""
saber-wang 9a0856c
Retain the _oauthstate parameter in redirect_uri
saber-wang 41426f9
Refactor _oauthstate handling
martincostello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add WechatTests
- Loading branch information
commit 7891b2540b58d9a17b869919f633bfb9f8a44635
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
test/AspNet.Security.OAuth.Providers.Tests/Wechat/WechatTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
| * See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers | ||
| * for more information concerning the license and the contributors participating to this project. | ||
| */ | ||
|
|
||
| using System.Security.Claims; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Authentication; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace AspNet.Security.OAuth.Weixin | ||
| { | ||
| public class WechatTests : OAuthTests<WeixinAuthenticationOptions> | ||
| { | ||
| public WechatTests(ITestOutputHelper outputHelper) | ||
| { | ||
| OutputHelper = outputHelper; | ||
| } | ||
|
|
||
| public override string DefaultScheme => WeixinAuthenticationDefaults.AuthenticationScheme; | ||
|
|
||
| protected internal override void RegisterAuthentication(AuthenticationBuilder builder) | ||
| { | ||
| builder.AddWeixin(options => | ||
| { | ||
| ConfigureDefaults(builder, options); | ||
| options.AuthorizationEndpoint = "https://open.weixin.qq.com/connect/oauth2/authorize"; | ||
| }); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(ClaimTypes.NameIdentifier, "my-id")] | ||
| [InlineData(ClaimTypes.Name, "John Smith")] | ||
| [InlineData(ClaimTypes.Gender, "Male")] | ||
| [InlineData(ClaimTypes.Country, "CN")] | ||
| [InlineData("urn:weixin:city", "Beijing")] | ||
| [InlineData("urn:weixin:headimgurl", "https://weixin.qq.local/image.png")] | ||
| [InlineData("urn:weixin:openid", "my-open-id")] | ||
| [InlineData("urn:weixin:privilege", "a,b,c")] | ||
| [InlineData("urn:weixin:province", "Hebei")] | ||
| public async Task Can_Sign_In_Using_Wechat(string claimType, string claimValue) | ||
| { | ||
| // Arrange | ||
| using (var server = CreateTestServer()) | ||
| { | ||
| // Act | ||
| var claims = await AuthenticateUserAsync(server); | ||
|
|
||
| // Assert | ||
| AssertClaim(claims, claimType, claimValue); | ||
| } | ||
| } | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
test/AspNet.Security.OAuth.Providers.Tests/Wechat/bundle.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json", | ||
| "items": [ | ||
| { | ||
| "uri": "https://api.weixin.qq.com/sns/oauth2/access_token?appid=my-client-id&secret=my-client-secret&code=a6ed8e7f-471f-44f1-903b-65946475f351&grant_type=authorization_code", | ||
| "contentFormat": "json", | ||
| "contentJson": { | ||
| "access_token": "secret-access-token", | ||
| "token_type": "access", | ||
| "refresh_token": "secret-refresh-token", | ||
| "expires_in": "300", | ||
| "openid": "my-open-id" | ||
| } | ||
| }, | ||
| { | ||
| "uri": "https://api.weixin.qq.com/sns/userinfo?access_token=secret-access-token&openid=my-open-id", | ||
| "contentFormat": "json", | ||
| "contentJson": { | ||
| "unionid": "my-id", | ||
| "nickname": "John Smith", | ||
| "sex": "Male", | ||
| "country": "CN", | ||
| "openid": "my-open-id", | ||
| "province": "Hebei", | ||
| "city": "Beijing", | ||
| "headimgurl": "https://weixin.qq.local/image.png", | ||
| "privilege": [ | ||
| "a", | ||
| "b", | ||
| "c" | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.