authorization

Custom Authorization in Asp.net WebApi - what a mess?

こ雲淡風輕ζ 提交于 2019-11-26 08:57:50
问题 I\'m reading from several resources (books and SO answers) about authorization in WebApi. Suppose I want to add Custom Attribute which allows access only for Certain Users: Case #1 I\'ve seen this approach of overriding OnAuthorization , which sets response if something is wrong public class AllowOnlyCertainUsers : AuthorizeAttribute { public override void OnAuthorization(HttpActionContext actionContext) { if ( /*check if user OK or not*/) { actionContext.Response = new HttpResponseMessage

Restrict access to a specific controller by IP address in ASP.NET MVC Beta

对着背影说爱祢 提交于 2019-11-26 08:54:52
问题 I have an ASP.NET MVC project containing an AdminController class and giving me URls like these: http://example.com/admin/AddCustomer http://examle.com/Admin/ListCustomers I want to configure the server/app so that URIs containing /Admin are only accessible from the 192.168.0.0/24 network (i.e. our LAN) I\'d like to restrict this controller to only be accessible from certain IP addresses. Under WebForms, /admin/ was a physical folder that I could restrict in IIS... but with MVC, of course,

ASP.NET MVC 4 custom Authorize attribute - How to redirect unauthorized users to error page? [duplicate]

主宰稳场 提交于 2019-11-26 08:16:25
问题 This question already has answers here : ASP.NET MVC - How to show unauthorized error on login page? (7 answers) Closed 6 years ago . I\'m using a custom authorize attribute to authorize users\' access based on their permission levels. I need to redirect unauthorized users (eg. user tries to delete an invoice without Delete acess level) to access denied page. The custom attribute is working. But in a case of unauthorized user access, nothing shown in the browser. Contoller Code. public class

asp.net mvc decorate [Authorize()] with multiple enums

北战南征 提交于 2019-11-26 07:59:29
问题 I have a controller and I want two roles to be able to access it. 1-admin OR 2-moderator I know you can do [Authorize(Roles=\"admin, moderators\")] but I have my roles in an enum. With the enum I can only authorize ONE role. I can\'t figure out how to authorize two. I have tried something like [Authorize(Roles=MyEnum.Admin, MyEnum.Moderator)] but that wont compile. Someone once suggested this: [Authorize(Roles=MyEnum.Admin)] [Authorize(MyEnum.Moderator)] public ActionResult myAction() { } but

ASP.NET MVC - How to show unauthorized error on login page?

北慕城南 提交于 2019-11-26 07:57:38
问题 In my ASP.NET MVC app, I have most controllers decorated with [Authorize(Roles=\"SomeGroup\")] When a user is not authorized to access something, they are sent to \"~/Login\" which is the Login action on my Account controller. How can I determine that a user has reached the login page because of not being authorized so that I can show an appropriate error? 回答1: You can look for the ?ReturnUrl= querystring value, or you can create your own authorization filter & set a field in TempData

Authorization header missing in django rest_framework, is apache to blame?

巧了我就是萌 提交于 2019-11-26 07:28:07
问题 I\'ve managed to extend TokenAuthentication and I have a working model when using the request session to store my tokens, however when I attempt to pass Authorization as a header parameter as described here, I noticed that my Responses come back without the META variable HTTP_AUTHORIZATION. I also noticed that if I pass \"Authorization2\" as a header parameter that it is visible in the request: { \'_content_type\': \'\', \'accepted_media_type\': \'application/json\', \'_request\':

Java: how to use UrlConnection to post request with authorization?

大兔子大兔子 提交于 2019-11-26 06:26:17
问题 I would like to generate POST request to a server which requires authentication. I tried to use the following method: private synchronized String CreateNewProductPOST (String urlString, String encodedString, String title, String content, Double price, String tags) { String data = \"product[title]=\" + URLEncoder.encode(title) + \"&product[content]=\" + URLEncoder.encode(content) + \"&product[price]=\" + URLEncoder.encode(price.toString()) + \"&tags=\" + tags; try { URL url = new URL(urlString

Is claims based authorization appropriate for individual resources

空扰寡人 提交于 2019-11-26 05:39:21
问题 I understand the usage of claims for things I would commonly refer to as \"roles\" or \"permissions\". I know that claims are more general, but from what I have seen in practice, it usually boils down to this: If user has this set of claims they can access certain areas, or perform certain functions. Imagine a wiki application. You might have a content_contributor claim that would allow a user to add content, a content_admin claim that would allow a user to remove content, and a modify_user

How do I set up access control in SVN?

和自甴很熟 提交于 2019-11-26 04:08:21
问题 I have set up a repository using SVN and uploaded projects. There are multiple users working on these projects. But, not everyone requires access to all projects. I want to set up user permissions for each project. How can I achieve this? 回答1: In your svn\repos\YourRepo\conf folder you will find two files, authz and passwd . These are the two you need to adjust. In the passwd file you need to add some usernames and passwords. I assume you have already done this since you have people using it:

Redirecting unauthorized controller in ASP.NET MVC

懵懂的女人 提交于 2019-11-26 04:06:42
问题 I have a controller in ASP.NET MVC that I\'ve restricted to the admin role: [Authorize(Roles = \"Admin\")] public class TestController : Controller { ... If a user who is not in the Admin role navigates to this controller they are greeted with a blank screen. What I would like to do is redirect them to View that says \"you need to be in the Admin role to be able to access this resource.\" One way of doing this that I\'ve thought of is to have a check in each action method on IsUserInRole()