mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-12-27 14:45:41 +08:00
增加SSO逻辑
This commit is contained in:
62
OpenAuth.WebTest/Views/Home/Index.cshtml
Normal file
62
OpenAuth.WebTest/Views/Home/Index.cshtml
Normal file
@@ -0,0 +1,62 @@
|
||||
@{
|
||||
ViewBag.Title = "Home Page";
|
||||
}
|
||||
|
||||
<div class="jumbotron">
|
||||
<h1>OpenAuth.NET</h1>
|
||||
<p class="lead">这是OpenAuth.Net的测试站点,模拟一个第三方网站如何使用OpenAuth.net提供的权限功能!</p>
|
||||
<p><a href="https://git.oschina.net/yubaolee/OpenAuth.Net" class="btn btn-primary btn-lg">Learn more »</a>
|
||||
</p>
|
||||
</div>
|
||||
<script src="~/Scripts/jquery-1.10.2.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$("#btnGetValue").click(function() {
|
||||
$.get("/Values/index", function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h2>登录</h2>
|
||||
<p>
|
||||
@if (ViewBag.CurrentUser != null)
|
||||
{
|
||||
<span> 当前登录用户:@ViewBag.CurrentUser.User.Account</span>
|
||||
<a href="/home/logout">退出</a>
|
||||
<button class="button alert-danger" id="btnGetValue">获取值</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a href="/home/login">点击这里登陆</a>
|
||||
}
|
||||
</p>
|
||||
<form class="form-group">
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
@if (ViewBag.CurrentUser != null)
|
||||
{
|
||||
<h2>可访问的机构</h2>
|
||||
<ul>
|
||||
@foreach (var org in ViewBag.CurrentUser.AccessedOrgs)
|
||||
{
|
||||
<li>@org.Name</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
<h2>可访问的资源</h2>
|
||||
<ul>
|
||||
@foreach (var resource in ViewBag.CurrentUser.Resources)
|
||||
{
|
||||
<li>@resource.Name</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
28
OpenAuth.WebTest/Views/Login/Index.cshtml
Normal file
28
OpenAuth.WebTest/Views/Login/Index.cshtml
Normal file
@@ -0,0 +1,28 @@
|
||||
@{
|
||||
ViewBag.Title = "title";
|
||||
}
|
||||
|
||||
<h2>Login</h2>
|
||||
|
||||
<form class="form-horizontal" method="POST">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="username">Email</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="username" name="username" value="admin">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="password">Password</label>
|
||||
<div class="controls">
|
||||
<input type="password" id="password" name="password" value="admin">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox"> Remember me
|
||||
</label>
|
||||
<button type="submit" class="btn">Sign in</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
14
OpenAuth.WebTest/Views/Shared/Error.cshtml
Normal file
14
OpenAuth.WebTest/Views/Shared/Error.cshtml
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>错误</title>
|
||||
</head>
|
||||
<body>
|
||||
<hgroup>
|
||||
<h1>登录失败</h1>
|
||||
<h2>用户名或密码错误</h2>
|
||||
</hgroup>
|
||||
</body>
|
||||
</html>
|
||||
41
OpenAuth.WebTest/Views/Shared/_Layout.cshtml
Normal file
41
OpenAuth.WebTest/Views/Shared/_Layout.cshtml
Normal file
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>@ViewBag.Title - OpenAuth.Net测试站点</title>
|
||||
@Styles.Render("~/Content/css")
|
||||
@Scripts.Render("~/bundles/modernizr")
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
@Html.ActionLink("OpenAuth.Net测试站点", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>@Html.ActionLink("主页", "Index", "Home")</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container body-content">
|
||||
@RenderBody()
|
||||
<hr />
|
||||
<footer>
|
||||
<p>© @DateTime.Now.Year - OpenAuth.Net测试站点</p>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@Scripts.Render("~/bundles/jquery")
|
||||
@Scripts.Render("~/bundles/bootstrap")
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
43
OpenAuth.WebTest/Views/Web.config
Normal file
43
OpenAuth.WebTest/Views/Web.config
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<system.web.webPages.razor>
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
<pages pageBaseType="System.Web.Mvc.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc" />
|
||||
<add namespace="System.Web.Mvc.Ajax" />
|
||||
<add namespace="System.Web.Mvc.Html" />
|
||||
<add namespace="System.Web.Optimization"/>
|
||||
<add namespace="System.Web.Routing" />
|
||||
<add namespace="OpenAuth.WebTest" />
|
||||
</namespaces>
|
||||
</pages>
|
||||
</system.web.webPages.razor>
|
||||
|
||||
<appSettings>
|
||||
<add key="webpages:Enabled" value="false" />
|
||||
</appSettings>
|
||||
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
|
||||
<system.web>
|
||||
<compilation>
|
||||
<assemblies>
|
||||
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
</assemblies>
|
||||
</compilation>
|
||||
</system.web>
|
||||
</configuration>
|
||||
3
OpenAuth.WebTest/Views/_ViewStart.cshtml
Normal file
3
OpenAuth.WebTest/Views/_ViewStart.cshtml
Normal file
@@ -0,0 +1,3 @@
|
||||
@{
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
Reference in New Issue
Block a user