Ver a proveniência

统一认证3.0

和田中职
ndbs há 3 meses
ascendente
cometimento
214e2fe4f5
4 ficheiros alterados com 30 adições e 11 eliminações
  1. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/Permission/Views/Perm_Function/Form.cshtml
  2. +2
    -2
      Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs
  3. +7
    -2
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/SSOApi.cs
  4. +20
    -6
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Security/DESEncrypt.cs

+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/Permission/Views/Perm_Function/Form.cshtml Ver ficheiro

@@ -16,7 +16,7 @@
<input id="FUrl" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" />
</div>
<div class="col-xs-12 lr-form-item" data-table="Perm_Function">
<div class="lr-form-item-title">登录接口地址<font face="宋体">*</font></div>
<div class="lr-form-item-title">退出地址<font face="宋体">*</font></div>
<input id="FInterfaceUrl" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" />
</div>
<div class="col-xs-12 lr-form-item" data-table="Perm_Function" style="display: none;" id="divFId">


+ 2
- 2
Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs Ver ficheiro

@@ -96,11 +96,11 @@ namespace Learun.Application.Web.Controllers
var url = perm_application.FInterfaceUrl;
if (url.Contains("?"))
{
url += "&appkey=" + DESEncrypt.Encrypt(code, "bjqjsso");
url += "&appkey=" + Md5Helper.Encrypt(perm_application.FSecret, 32) + "&name=" + DESEncrypt.Encrypt(userinfo.realName, perm_application.FSecret, false) + "&no=" + DESEncrypt.Encrypt(userinfo.enCode, perm_application.FSecret, false) + "&no=" + DESEncrypt.Encrypt(userinfo.enCode);
}
else
{
url += "?appkey=" + DESEncrypt.Encrypt(code, "bjqjsso");
url += "?appkey=" + Md5Helper.Encrypt(perm_application.FSecret, 32) + "&name=" + DESEncrypt.Encrypt(userinfo.realName, perm_application.FSecret, false) + "&no=" + DESEncrypt.Encrypt(userinfo.enCode, perm_application.FSecret, false) + "&no=" + DESEncrypt.Encrypt(userinfo.enCode);
}
return Redirect(url);
}


+ 7
- 2
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/SSOApi.cs Ver ficheiro

@@ -153,14 +153,19 @@ namespace Learun.Application.WebApi.Modules
//写入当前请求所登录的用户
var code = Util.CommonHelper.RndNum(9);
cache.Write(code, userinfo.account, TimeSpan.FromMinutes(10));
string tyrz = ConfigurationManager.AppSettings["tyrz"];
if (!perm_application.FSecret.IsEmpty())
{
tyrz = perm_application.FSecret;
}
var url = perm_application.FInterfaceUrl;
if (url.Contains("?"))
{
url += "&appkey=" + DESEncrypt.Encrypt(code, "bjqjsso");
url += "&appkey=" + Md5Helper.Encrypt("tyrz", 32) + "&name=" + DESEncrypt.Encrypt(userinfo.realName, "tyrz") + "&no=" + DESEncrypt.Encrypt(userinfo.enCode, "tyrz");
}
else
{
url += "?appkey=" + DESEncrypt.Encrypt(code, "bjqjsso");
url += "?appkey=" + Md5Helper.Encrypt("tyrz", 32) + "&name=" + DESEncrypt.Encrypt(userinfo.realName, "tyrz") + "&no=" + DESEncrypt.Encrypt(userinfo.enCode, "tyrz");
}
return Success(new{ FInterfaceUrl=url });
}


+ 20
- 6
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Security/DESEncrypt.cs Ver ficheiro

@@ -31,13 +31,20 @@ namespace Learun.Util
/// <param name="Text">需要加密的内容</param>
/// <param name="sKey">秘钥</param>
/// <returns></returns>
public static string Encrypt(string Text, string sKey)
public static string Encrypt(string Text, string sKey, bool md5 = true)
{
var key = sKey;
var iv = sKey;
if (md5)
{
key = Md5Helper.Hash(sKey).ToUpper().Substring(0, 8);
iv = Md5Helper.Hash(sKey).ToUpper().Substring(0, 8);
}
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray;
inputByteArray = Encoding.Default.GetBytes(Text);
des.Key = ASCIIEncoding.ASCII.GetBytes(Md5Helper.Hash(sKey).ToUpper().Substring(0, 8));
des.IV = ASCIIEncoding.ASCII.GetBytes(Md5Helper.Hash(sKey).ToUpper().Substring(0, 8));
des.Key = ASCIIEncoding.ASCII.GetBytes(key);
des.IV = ASCIIEncoding.ASCII.GetBytes(iv);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
@@ -75,8 +82,15 @@ namespace Learun.Util
/// <param name="Text">需要解密的内容</param>
/// <param name="sKey">秘钥</param>
/// <returns></returns>
public static string Decrypt(string Text, string sKey)
public static string Decrypt(string Text, string sKey, bool md5 = true)
{
var key = sKey;
var iv = sKey;
if (md5)
{
key = Md5Helper.Hash(sKey).ToUpper().Substring(0, 8);
iv = Md5Helper.Hash(sKey).ToUpper().Substring(0, 8);
}
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
int len;
len = Text.Length / 2;
@@ -87,8 +101,8 @@ namespace Learun.Util
i = Convert.ToInt32(Text.Substring(x * 2, 2), 16);
inputByteArray[x] = (byte)i;
}
des.Key = ASCIIEncoding.ASCII.GetBytes(Md5Helper.Hash(sKey).ToUpper().Substring(0, 8));
des.IV = ASCIIEncoding.ASCII.GetBytes(Md5Helper.Hash(sKey).ToUpper().Substring(0, 8));
des.Key = ASCIIEncoding.ASCII.GetBytes(key);
des.IV = ASCIIEncoding.ASCII.GetBytes(iv);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);


Carregando…
Cancelar
Guardar