authorization

How to conditionally display elements of JSP page depending on user role

房东的猫 提交于 2019-11-29 08:54:10
How to load menu on webpage depends upon login user? I want to make websites where some menu will show before login and after login it will show more menu depends upon login user if admin is login then some administraive menu will appear if normal user is login then some different menu will be added. I want to build this project using JSP/Servlet. When user click on any menu total page will not be reloaded only some part will be changed where show the details description of this menu. BalusC You can just use JSTL to programmatically control the flow in the HTML output of the JSP. You can check

Dynamically add roles to authorize attribute for controller in ASP.NET 5

a 夏天 提交于 2019-11-29 07:44:48
I have a sample question with this post Dynamically add roles to authorize attribute for controller but for ASP.NET 5 (vNext) In ASP.NET 5, I can not overwrite AuthorizeAttribute class as above post said. So how can I add roles dynamically Controllers in ASP.NET 5 (vNext) Thanks in advance. As mike mentioned, you need policies. Here is one implementation. public class CustomRoleRequirement : AuthorizationHandler<CustomRoleRequirement>, IAuthorizationRequirement { protected override void Handle(Microsoft.AspNet.Authorization.AuthorizationContext context, CustomRoleRequirement requirement) { var

asp.net mvc [Authorize()] attribute for mixed group and user

烈酒焚心 提交于 2019-11-29 07:34:41
I am using ASP.NET MVC 1.1 with Windows authentication. I trying to only authorize members of a group and myself. I am not a member of the group and would not need to be a member of this group. I am getting windows login/password prompt every time I access the URL of the web app. The HomeController has [HandleError] [Authorize(Roles=@"MyDomain\\company.security.group.name")] [Authorize(Users=@"MyDoamin\\MyName")] [OutputCache(Duration=86400,VaryByParam="PageIndex")] public class HomeController : Controller How do I enable such authorization? The web app is running under a site on IIS6. The

Symfony 2.3 getRequest()->headers not showing Authorization Bearer Token

拥有回忆 提交于 2019-11-29 07:30:51
I am passing an Authorization: Bearer { Token } as a HTTP request to my Symfony Rest Controller. My Request: GET /app_dev.php/api/members HTTP/1.1 Host: localhost Authorization: Bearer 123456789 Cache-Control: no-cache Content-Type: application/x-www-form-urlencoded Inside My controller: $this->getRequest()->headers; For some reason when I use Symfony's Request method the Authorization header isn't available to my controller. When I use PHP's getallheaders() the Authorization header shows up as expected. Any Ideas on why Symfony isn't seeing it? Thanks It is most likely stripped by Apache.

ASP.Net MVC how to determine if a user can access a URL?

ⅰ亾dé卋堺 提交于 2019-11-29 06:19:53
问题 So I was reading another question regarding login loop when you have a user logging in, set to return to a URL which they might not have access to after logging in (ie. an admin page, and the user logs in with a normal account). The solution under WebForms seems to be to utilize the UrlAuthorizationModule.CheckUrlAccessForPrincipal method. However that does not work for URLs going to Action Methods secured with the Authorize Attribute. I figured I could work out which method the URL was

Which HTTP status code to say username or password were incorrect?

北城余情 提交于 2019-11-29 05:30:09
I am implementing a simple registation/login module. While testing user credentials, I start thinking which HTTP status code will be appropriate, for the situation if a user send a request with incorrect credentials. At first, I thought 401 Unauthorized would be a nice status code, but it seems it will be better to use it when a user is trying to get some resource without authorisation. After, I switched to 409 Conflict This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request. So, friends, please give me an advise

Divert to alternate homepage if user is not logged in using UI-Router & AngularJS

ぐ巨炮叔叔 提交于 2019-11-29 05:20:06
I would like to have two home pages, the first would be for users who have not logged in and the second for users that are logged in. This is my current set up: .config(function ($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider) { $urlRouterProvider .otherwise('/'); $locationProvider.html5Mode(true); $httpProvider.interceptors.push('authInterceptor'); }) .factory('authInterceptor', function ($rootScope, $q, $cookieStore, $location) { return { // Add authorization token to headers request: function (config) { config.headers = config.headers || {}; if ($cookieStore.get('token

ASP.NET MVC authorization & permission to use model classes

久未见 提交于 2019-11-29 05:18:55
问题 This is my first post here, so hello :) Okay, let's get to the point... I am writing my first app in ASP.NET MVC Framework and i have a problem with checking privileges to use instances of model classes (read, edit). Sample code looks like this: // Controller action [CustomAuthorize(Roles="Editor, Admin")] public ActionResult Stats(int id) { User user = userRepository.GetUser(id); if (user == null || !user.Activated || user.Removed) return View("NotFound"); else if (!user

Authentication through web.config not authenticating in ASP.net 3.5

对着背影说爱祢 提交于 2019-11-29 03:45:30
This is one of this things that should be extremely simple and I just can't work out why it's not working. I'm trying to set up some very quick authentication for an ASP.net 3.5 app but storing the usernames and passwords in the web.config file (I know it's not very secure but it's an internal app that I keep getting asked to add and remove logins for so this is the quickest way to do it). So, the relevant config section looks like this: <authentication mode="Forms"> <forms loginUrl="~/login.aspx"> <credentials> <user name="user" password="password" /> <user name="user2" password="password2" /

Defer Angular UI Router $stateChangeStart until server authorization response receieved

北战南征 提交于 2019-11-29 03:44:38
I have an Angular app using UI Router where I'm trying to validate a user's token, if one exists, when the app runs. I am also checking that the user has permission to access certains routes. The problem is that $stateChangeStart is running before I receive the response back from the authorization endpoint. Here's some code (coffeescript with js below) - this is all within my run block. app.run(($rootScope, $state, $stateParams, $log, Auth) -> currentState = 'home' $rootScope.$state = $state # read a cookie if cookie exists if Auth.setAuthenticationToken() # hit api endpoint to validate token