asp.net – AngularJs ServiceStack应用程序的安全性
发布时间:2020-12-16 09:25:08 所属栏目:asp.Net 来源:网络整理
导读:我有一个应用程序在前端有四个模块,我正在尝试尽可能多地使用前端的AngularJs我正在使用一个空网站asp.net项目来托管所有文件和REST serviceStack,我的项目有以下几种结构: ~/ (web.config,global.asax and all the out of the box structure for an asp.ne
我有一个应用程序在前端有四个模块,我正在尝试尽可能多地使用前端的AngularJs我正在使用一个空网站asp.net项目来托管所有文件和REST serviceStack,我的项目有以下几种结构:
~/ (web.config,global.asax and all the out of the box structure for an asp.net website) - App <- AngularJs - Users <- js controllers and views (static html files) - Companies - BackEnd - Public Index.html IndexCtrl.js App.js - Content - Js 我使用angularjs服务调用和后端我使用REST与servicestack. 问题是如何限制只有经过身份验证的用户访问那些静态html文件?比如公司,后端和用户内部的那些 解决方法
嗨在做了一些研究后,这是对我有用的解决方案:
>从nuget安装razor markdown 为了说明这一点,这是我到目前为止的路线定义: 'use strict'; angular.module('myApp',['myApp.directives','myApp.services']).config( ['$routeProvider',function($routeProvider) { $routeProvider.when('/Dashboard',{ controller: 'dashboardCtrl',templateUrl: 'Views/dashboard' }).when('/Payments',{ controller: 'paymentsCtrl',templateUrl: 'Views/payments' }). when('/Login',{ controller: 'loginCtrl',templateUrl: 'Views/login' }); }] ); 请注意,引用现在指向剃刀路径. 这是一个小角度的菜单 <div class="container"> <div class="navbar" ng-controller="indexCtrl"> <div class="navbar-inner"> <a class="brand" href="#/">header menu</a> <ul class="nav"> <li ng-class="{active: routeIs('/Dashboard')}"><a href="#/Dashboard">Dashboard</a></li> <li ng-class="{active: routeIs('/Login')}"><a href="#/Login">Login</a></li> <li ng-class="{active: routeIs('/Payments')}"><a href="#/Payments">payments</a></li> </ul> </div> </div> <ng-view></ng-view> </div> 假设付款页面受到限制,因此每次点击页面时我都会收到401未经授权的邮件. 服务主持人: public override void Configure(Container container) { Plugins.Add(new AuthFeature(() => new AuthUserSession(),new IAuthProvider[] { new FacebookAuthProvider(appSettings),new TwitterAuthProvider(appSettings),new BasicAuthProvider(appSettings),new GoogleOpenIdOAuthProvider(appSettings),new CredentialsAuthProvider() })); //I'm going to support social auth as well. Plugins.Add(new RegistrationFeature()); Routes.Add<UserRequest>("/Api/User/{Id}"); Routes.Add<LoginRequest>("/Api/User/login","POST"); Routes.Add<PaymentRequest>("/views/Payments"); } 我希望有所帮助 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- 用户锁定.net 4.5.1 ASP.NET MVC 5
- asp.net-mvc – 在应用程序池回收后,如何预热我的
- asp.net-mvc-5 – ASP.NET MVC 5捆绑和缩小Javas
- asp.net-mvc – Kendo ASP.NET MVC – 索引超出范
- asp.net-mvc-3 – MVC EditorFor命名模板的问题
- HTTP 错误 404.3 - Not Found 由于扩展配置问题而
- .net – VBPROJ / CSPROJ
- asp.net – 当浏览器在HTTP Request标头中设置“
- asp.net-mvc – 是否可以在ASP .NET MVC中使用没
- ASP.NET Web API v2并使用E??LMAH记录所有错误/异
热点阅读