更换jwtToken 为Bearer
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Infrastructure
|
||||
|
||||
static ConfigUtils()
|
||||
{
|
||||
Config = App.ServiceProvider.GetRequiredService<IConfiguration>();
|
||||
Configuration = App.ServiceProvider.GetRequiredService<IConfiguration>();
|
||||
|
||||
if (Instance == null)
|
||||
Instance = new ConfigUtils();
|
||||
@@ -22,35 +22,22 @@ namespace Infrastructure
|
||||
|
||||
public static ConfigUtils Instance { get; private set; }
|
||||
#endregion
|
||||
|
||||
private static IConfiguration Config { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 泛型读取配置文件
|
||||
/// 目前还不能绑定到实体类
|
||||
/// </summary>
|
||||
/// <param name="defaultValue">获取不到配置文件设定默认值</param>
|
||||
/// <param name="key">要获取的配置文件节点名称</param>
|
||||
/// <returns></returns>
|
||||
//public T GetConfig<T>(string key, T defaultValue = default)
|
||||
//{
|
||||
// //GetValue扩展包需要安装Microsoft.Extensions.Configuration
|
||||
// var setting = Config.GetValue(key, defaultValue);
|
||||
|
||||
// Console.WriteLine($"获取配置文件值key={key},value={setting}");
|
||||
// return setting;
|
||||
//}
|
||||
private static IConfiguration Configuration { get; set; }
|
||||
|
||||
public T GetAppConfig<T>(string key, T defaultValue = default(T))
|
||||
{
|
||||
T setting = (T)Convert.ChangeType(Config[key], typeof(T));
|
||||
T setting = (T)Convert.ChangeType(Configuration[key], typeof(T));
|
||||
var value = setting;
|
||||
if (setting == null)
|
||||
value = defaultValue;
|
||||
//Console.WriteLine($"获取配置文件值key={key},value={value}");
|
||||
return value;
|
||||
}
|
||||
|
||||
public T Bind<T>(string key, T t)
|
||||
{
|
||||
Configuration.Bind(key, t);
|
||||
|
||||
return t;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取配置文件
|
||||
/// </summary>
|
||||
@@ -58,7 +45,7 @@ namespace Infrastructure
|
||||
/// <returns></returns>
|
||||
public string GetConfig(string key)
|
||||
{
|
||||
return Config[key];
|
||||
return Configuration[key];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -66,10 +53,9 @@ namespace Infrastructure
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public string GetConnectionStrings(string key)
|
||||
public string GetConnectionString(string key)
|
||||
{
|
||||
return Config.GetConnectionString(key);
|
||||
|
||||
return Configuration.GetConnectionString(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,4 +50,27 @@ namespace Infrastructure
|
||||
public string KEY { get; set; }
|
||||
public string SECRET { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Jwt
|
||||
/// </summary>
|
||||
public class JwtSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// token是谁颁发的
|
||||
/// </summary>
|
||||
public string Issuer { get; set; }
|
||||
/// <summary>
|
||||
/// token可以给那些客户端使用
|
||||
/// </summary>
|
||||
public string Audience { get; set; }
|
||||
/// <summary>
|
||||
/// 加密的key(SecretKey必须大于16个,是大于,不是大于等于)
|
||||
/// </summary>
|
||||
public string SecretKey { get; set; }
|
||||
/// <summary>
|
||||
/// token时间(分)
|
||||
/// </summary>
|
||||
public int Expire { get; set; } = 1440;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user