Browse Source

auth2.0

大厂分支
liangkun 4 years ago
parent
commit
b7e012ba6e
10 changed files with 196 additions and 12 deletions
  1. +72
    -0
      Learun.Framework.Ultimate V7/Doc文档/数字化智慧校园统一身份认证oauth2.0对接说明V1.0.docx
  2. +4
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/Permission/Views/Perm_Function/Form.cshtml
  3. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/Permission/Views/Perm_Function/Form.js
  4. +25
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs
  5. +44
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/SSOSystemController.cs
  6. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
  7. +34
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Home/GoToApplication.cshtml
  8. +10
    -7
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Home/SSOApplication.cshtml
  9. +4
    -4
      Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/database.config
  10. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs

+ 72
- 0
Learun.Framework.Ultimate V7/Doc文档/数字化智慧校园统一身份认证oauth2.0对接说明V1.0.docx View File

@@ -0,0 +1,72 @@


数字化智慧校园





统一身份认证oauth2.0
对接说明






V1.0


概述
由于各学校存在N套系统,各系统都存在自己独立的用户登录验证,给使用者造成了许多重复操作,也容易造成帐户密码混乱及丢失的情况。为了低成本的解决以上问题,我公司特开发了基于原系统验证方式、无需统一使用用户库的解决方案。
对接方当前所使用的用户验证体系无需更改,仅需增加数据解密部分代码。
实现逻辑
标准oauth2.0认证。
统一身份认证工作机制说明
第一步,各对接方在数字化智慧校园系统中配置统一身份认证的登录接口地址
我方提供配置UI
外网测试地址:
http://demo.bjquanjiang.com:8081/ 测试用户名:thirdtest密码:123456
学校内网地址:
依照学校实际地址
系统登录

应用添加

应用配置

权限配置

查看个人应用
点击【进入系统】访问

跳转页面如下图

至此,统一应用端配置完毕。

第二步 获取授权码(authorization code)
采用标准Http Get请求方式,code有效期为10分钟
请求地址:http://demo.bjquanjiang.com:8081/SSOSystem/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code
参数说明
参数
是否必须
说明
appid
应用唯一标识
redirect_uri
获取授权码成功后重定向到的地址
请使用urlEncode对链接进行处理
response_type
填code
获取到code后,授权系统会重定向到redirect_uri地址并携带code参数,例如:
http://demo.bjquanjiang.com:8081/Login/CheckLoginForSSO20?code=CODE
第三步:通过code获取access_token
通过code获取access_token

示例代码仅供参考:
C#


+ 4
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/Permission/Views/Perm_Function/Form.cshtml View File

@@ -19,6 +19,10 @@
<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">
<div class="lr-form-item-title">appid</div>
<input id="FId" type="text" class="form-control" disabled="disabled" />
</div>
<div class="col-xs-12 lr-form-item" data-table="Perm_Function">
<div class="lr-form-item-title">应用私钥<font face="宋体">*</font></div>
<input id="FSecret" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" />


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/Permission/Views/Perm_Function/Form.js View File

@@ -43,6 +43,7 @@ var bootstrap = function ($, learun) {
$('[data-table="' + id + '"]').lrSetFormData(data[id]);
}
}
$("#divFId").css("display","block");
});
}
}


+ 25
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs View File

@@ -15,6 +15,7 @@ using Learun.Application.TwoDevelopment.LogisticsManagement;
using System.Linq;
using Learun.Application.OA;
using Learun.Application.TwoDevelopment.LR_Desktop;
using Learun.Application.TwoDevelopment.Permission;
using Learun.Application.WorkFlow;

namespace Learun.Application.Web.Controllers
@@ -54,6 +55,7 @@ namespace Learun.Application.Web.Controllers
private Sys_ReceiveFileIBLL sys_ReceiveFileIBLL = new Sys_ReceiveFileBLL();

private Sys_UpdateRecordIBLL sys_UpdateRecordIBLL = new Sys_UpdateRecordBLL();
private Perm_FunctionIBLL perm_FunctionIBLL = new Perm_FunctionBLL();
#region 视图功能

public ActionResult ChangePwd()
@@ -61,11 +63,34 @@ namespace Learun.Application.Web.Controllers
return View();
}

#region 统一身份认证2.0
public ActionResult SSOApplication()
{
var userinfo = LoginUserInfo.Get();
ViewBag.FunctionList = perm_FunctionIBLL.GetListByUserId(userinfo.userId);
return View();
}
/// <summary>
/// 跳转网站
/// </summary>
/// <returns></returns>
public ActionResult GoToApplication()
{
string redi = Request.QueryString["redi"];
if (!string.IsNullOrEmpty(redi))
{
var perm_application = perm_FunctionIBLL.GetPerm_FunctionEntity(Request.QueryString["appid"]);
if (perm_application != null)
{
return Redirect(perm_application.FInterfaceUrl);
}
else
return RedirectToAction("Index");
}
return View();
}

#endregion
public ActionResult NeedToDoForm()
{
var userinfo = LoginUserInfo.Get();


+ 44
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/SSOSystemController.cs View File

@@ -35,6 +35,50 @@ namespace Learun.Application.Web.Controllers
private Sys_ReceiveFileIBLL sys_ReceiveFileIBLL = new Sys_ReceiveFileBLL();
private Perm_FunctionVisitIBLL functionVisitIbll = new Perm_FunctionVisitBLL();

#region 统一身份认证2.0
/// <summary>
/// 请求code
/// </summary>
/// <returns></returns>
public ActionResult authorize()
{
string appid = Request.QueryString["appid"];
string redirect_uri = Request.QueryString["redirect_uri"];
string response_type = Request.QueryString["response_type"];
if (string.IsNullOrEmpty(appid))
{
return Fail("参数:appid不能为空");
}
if (string.IsNullOrEmpty(redirect_uri))
{
return Fail("参数:redirect_uri不能为空");
}
if (string.IsNullOrEmpty(response_type))
{
return Fail("参数:response_type不能为空");
}
if (response_type!="code")
{
return Fail("参数:response_type必须为code");
}
var application = perm_FunctionIBLL.GetPerm_FunctionEntity(appid);
if (application != null)
{
if (application.FInterfaceUrl.Equals(redirect_uri))
{
var code = appid + Util.CommonHelper.RndNum(9);
return Success("");
}
else
{
return Fail("未授权的redirect_uri");
}
}
else
return Fail("未授权的appid");
}

#endregion
public ActionResult Index()
{
string account = "";


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj View File

@@ -6905,6 +6905,7 @@
<Content Include="Views\Login\PageThreeWxLogin.cshtml" />
<Content Include="Views\Login\PageTwoWxLogin.cshtml" />
<Content Include="Views\Home\SSOApplication.cshtml" />
<Content Include="Views\Home\GoToApplication.cshtml" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />


+ 34
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Home/GoToApplication.cshtml View File

@@ -0,0 +1,34 @@
@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>统一身份认证平台</title>
<script src="~/Content/jquery/jquery-1.10.2.min.js"></script>
<script>
function request(d) { for (var c = location.search.slice(1).split("&"), a = 0; a < c.length; a++) { var b = c[a].split("="); if (b[0] == d) if ("undefined" == unescape(b[1])) break; else return unescape(b[1]) } return "" };
</script>

<script type="text/javascript">
$(function () {
setTimeout(function () {
location.href = '/Home/GoToApplication?redi=1&appid=' + request('appid');
}, 1000);
});
</script>
</head>
<body>
<div style="width: 100%; text-align: center;">
<div style="margin-top: 10%;">
<img src="~/Content/sso/fx.png" />
</div>
<div style="color: #959595; font-size: 14px; padding-top: 40px;">IDENTITY AUTHENTICATION</div>
<div style="text-align:center;font-size:26px; line-height:40px; padding-bottom:25px; color:#3d3d3d;">统一身份认证平台</div>
<div style="text-align:center; font-size:15px; color:#fe7511;">系统认证中,请耐心等待...</div>
</div>
</body>
</html>

+ 10
- 7
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Home/SSOApplication.cshtml View File

@@ -1,4 +1,5 @@
@{
@using Learun.Application.TwoDevelopment.Permission
@{
ViewBag.Title = "title";
Layout = "~/Views/Shared/_Index.cshtml";
}
@@ -131,13 +132,15 @@
</style>
<div class="lr-desktop-panel lr-scroll-wrap" style="overflow: auto;">
<div class="nav">
<div class="navClo6">
<div class="navBox navMoreBox" id="0f7a71fe-a95d-47a6-b8b3-854862a36225" style="background: #8564D8; border-color: #8564D8;">
<div class="navT"><i class="fa fa-caret-square-o-down lr-menu-item-icon"></i><span>地区管理</span></div>
<div class="navMore" style="color: #8564D8">进入系统 <i class="fa fa-caret-right"></i></div>
@foreach (Perm_FunctionEntity permFunctionEntity in ViewBag.FunctionList)
{
<div class="navClo6">
<div class="navBox navMoreBox" id="0f7a71fe-a95d-47a6-b8b3-854862a36225" style="background: #8564D8; border-color: #8564D8;">
<div class="navT"><i class="fa fa-caret-square-o-down lr-menu-item-icon"></i><span>@permFunctionEntity.FName</span></div>
<div class="navMore" style="color: #8564D8"><a href="/Home/GoToApplication?appid=@permFunctionEntity.FId" target="_blank">进入系统</a> <i class="fa fa-caret-right"></i></div>
</div>
</div>
</div>

}
</div>
</div>


+ 4
- 4
Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/database.config View File

@@ -9,16 +9,16 @@
<add name="CollegeMIS" connectionString="Server=192.168.2.126;Initial Catalog=CollegeMIS;User ID=sa;Password=bjqj@2015!" providerName="System.Data.SqlClient" />
<add name="hangfireString" connectionString="Server=192.168.2.126;Initial Catalog=Hangfire;User ID=sa;Password=bjqj@2015!" providerName="System.Data.SqlClient" />-->
<!--西昌-->
<!--<add name="BaseDb" connectionString="Server=112.45.152.8;Initial Catalog=adms7ultimate2;User ID=sa;Password=qj@2018" providerName="System.Data.SqlClient" />
<add name="BaseDb" connectionString="Server=112.45.152.8;Initial Catalog=adms7ultimate2;User ID=sa;Password=qj@2018" providerName="System.Data.SqlClient" />
<add name="CollegeMIS" connectionString="Server=112.45.152.8;Initial Catalog=NewCollegeMIS;User ID=sa;Password=qj@2018" providerName="System.Data.SqlClient" />
<add name="hangfireString" connectionString="Server=112.45.152.8;Initial Catalog=HangFire;User ID=sa;Password=qj@2018" providerName="System.Data.SqlClient" />-->
<add name="hangfireString" connectionString="Server=112.45.152.8;Initial Catalog=HangFire;User ID=sa;Password=qj@2018" providerName="System.Data.SqlClient" />
<!--demo.quanjiang.com-->
<!--<add name="BaseDb" connectionString="Server=123.57.209.16;Initial Catalog=adms7ultimate2;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="CollegeMIS" connectionString="Server=123.57.209.16;Initial Catalog=CollegeMIS;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="hangfireString" connectionString="Server=123.57.209.16;Initial Catalog=Hangfire;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />-->
<add name="BaseDb" connectionString="Server=123.57.209.16;Initial Catalog=adms7ultimate2_西昌;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<!--<add name="BaseDb" connectionString="Server=123.57.209.16;Initial Catalog=adms7ultimate2_西昌;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="CollegeMIS" connectionString="Server=123.57.209.16;Initial Catalog=CollegeMIS_西昌;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="hangfireString" connectionString="Server=123.57.209.16;Initial Catalog=Hangfire;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="hangfireString" connectionString="Server=123.57.209.16;Initial Catalog=Hangfire;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />-->

<!--<add name="BaseDb" connectionString="Server=123.57.209.16;Initial Catalog=adms7ultimate2_20200403test;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="CollegeMIS" connectionString="Server=123.57.209.16;Initial Catalog=CollegeMIS_20200403test;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />


+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs View File

@@ -817,7 +817,7 @@ WHERE (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + string
MajorNo = altitem.MajorNo,
LessonNo = altitem.LessonNo,
Grade = classData.FirstOrDefault(m => m.ClassNo == altitem.TeachClassNo)?.Grade,
LessonSortNo = altitem.LessonSortNo,
LessonSortNo ="1",
TeachClassNo = altitem.TeachClassNo,
EmpNo = altitem.EmpNo,
F_SchoolId = altitem.F_SchoolId


Loading…
Cancel
Save