zhaolei
5 days ago 4a2e5b9a21940f11757be37d99f0944e240e908b
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
39
40
41
42
using Microsoft.AspNetCore.Authentication.OAuth;
using Microsoft.AspNetCore.Authentication.OAuth.Claims;
using System.Collections.Generic;
using System.Security.Claims;
 
namespace Prow.OAuth
{
    /// <summary>
    /// OAuthOptions 配置类
    /// </summary>
    public abstract class LgbOAuthOptions : OAuthOptions
    {
        /// <summary>
        /// 默认构造函数
        /// </summary>
        public LgbOAuthOptions()
        {
            ClaimActions.Add(new JsonKeyClaimAction(ClaimTypes.Name, ClaimValueTypes.String, "login"));
            Events.OnRemoteFailure = context =>
            {
                context.Response.Redirect(HomePath);
                context.HandleResponse();
                return System.Threading.Tasks.Task.CompletedTask;
            };
        }
 
        /// <summary>
        /// 获得/设置 登陆后首页
        /// </summary>
        public string HomePath { get; set; } = "";
 
        /// <summary>
        /// 获得 配置授权角色列表
        /// </summary>
        public ICollection<string> Roles { get; } = new HashSet<string>();
 
        /// <summary>
        /// 获得/设置 默认授权 App
        /// </summary>
        public string App { get; set; } = "";
    }
}