using System.Collections.Generic;
using System.Text;
using Microsoft.IdentityModel.Tokens;

namespace IRaCIS.Core.Application.Auth
{
    public class JwtSetting
    {
        /// <summary>
        /// 颁发者
        /// </summary>
        public string Issuer { get; set; } = String.Empty;

        /// <summary>
        /// 接收者
        /// </summary>
        public string Audience { get; set; } = String.Empty;

        /// <summary>
        /// 令牌密码
        /// </summary>
        public string SecurityKey { get; set; } = String.Empty;

        /// <summary>
        ///  过期时间
        /// </summary>
        public int TokenExpireDays { get; set; }

        //public Dictionary<string, object> Claims { get; set; }

        /// <summary>
        /// 签名
        /// </summary>
        public SigningCredentials Credentials
        {
            get
            {
                var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(SecurityKey));
                return new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
            }
        }
    }
}
