-
Notifications
You must be signed in to change notification settings - Fork 529
/
BaiduAuthenticationOptions.cs
38 lines (33 loc) · 1.45 KB
/
BaiduAuthenticationOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* 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.Net;
using System.Security.Claims;
using Microsoft.AspNetCore.Http;
namespace AspNet.Security.OAuth.Baidu;
/// <summary>
/// Defines a set of options used by <see cref="BaiduAuthenticationHandler"/>.
/// </summary>
public class BaiduAuthenticationOptions : OAuthOptions
{
public BaiduAuthenticationOptions()
{
ClaimsIssuer = BaiduAuthenticationDefaults.Issuer;
CallbackPath = BaiduAuthenticationDefaults.CallbackPath;
AuthorizationEndpoint = BaiduAuthenticationDefaults.AuthorizationEndpoint;
TokenEndpoint = BaiduAuthenticationDefaults.TokenEndpoint;
UserInformationEndpoint = BaiduAuthenticationDefaults.UserInformationEndpoint;
ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "uid");
ClaimActions.MapJsonKey(ClaimTypes.Name, "uname");
ClaimActions.MapCustomJson(BaiduAuthenticationConstants.Claims.Portrait,
user =>
{
var portrait = user.GetString("portrait");
return string.IsNullOrWhiteSpace(portrait) ?
null :
$"https://tb.himg.baidu.com/sys/portrait/item/{WebUtility.UrlEncode(portrait)}";
});
}
}