authorization

Customizing authorization in ASP.NET MVC

江枫思渺然 提交于 2019-11-26 10:23:26
问题 My Controller class is decorated with an AuthorizeAttribute to protect the actions: [Authorize(Roles = \"User Level 2\")] public class BuyController : Controller { ... } Anytime an action is invoked but the user is not in at least the role \"User Level 2\" he is automatically redirected to the login page with a url like this: http://localhost:1436/Account/Login?ReturnUrl=%2fBuy If the user is already logged in, but doesn\'t have the right security level, this is not an optimal behavior! It

Custom HTTP Authorization Header

核能气质少年 提交于 2019-11-26 10:08:12
问题 I was wondering if it\'s acceptable to put custom data in an HTTP authorization header. We\'re designing a RESTful API and we may need a way to specify a custom method of authorization. As an example, let\'s call it FIRE-TOKEN authentication. Would something like this be valid and allowed according to the spec: Authorization: FIRE-TOKEN 0PN5J17HBGZHT7JJ3X82:frJIUN8DYpKDtOLCwo//yllqDzg= The first part of the second string (before the \':\') is the API key, the second part is a hash of query

How to scrape a website that requires login first with Python

别等时光非礼了梦想. 提交于 2019-11-26 10:08:03
问题 First of all, I think it\'s worth saying that, I know there are a bunch of similar questions but NONE of them works for me... I\'m a newbie on Python, html and web scraper. I\'m trying to scrape user information from a website which needs to login first. In my tests I use scraper my email settings from github as examples. The main page is \'https://github.com/login\' and the target page is \'https://github.com/settings/emails\' Here are a list of methods I\'ve tried ##########################

REST API Authorization & Authentication (web + mobile)

会有一股神秘感。 提交于 2019-11-26 10:04:35
问题 I\'ve read about oAuth, Amazon REST API, HTTP Basic/Digest and so on but can\'t get it all into \"single piece\". This is probably the closest situation - Creating an API for mobile applications - Authentication and Authorization I would like to built API-centric website - service. So (in the beginning) I would have an API in center and website (PHP + MySQL) would connect via cURL , Android and iPhone via their network interfaces. So 3 main clients - 3 API keys. And any other developer could

MongoDB 3.2 authentication failed

你说的曾经没有我的故事 提交于 2019-11-26 09:34:42
问题 I create a user with the following set of commands. This should create user in both admin db as well as my target db ( c2d ): # mongo 127.0.0.1:27017 MongoDB shell version: 3.2.6-29-g5c19788 connecting to: 127.0.0.1:27017/test > use admin switched to db admin > show collections system.users system.version > db.system.users.find() > db.createUser({user:\"cd2\", pwd:\"cd2\", roles:[{role:\"dbOwner\", db: \"c2d\"}]}) Successfully added user: { \"user\" : \"cd2\", \"roles\" : [ { \"role\" : \

Accessing post or get parameters in custom authorization MVC4 Web Api

拥有回忆 提交于 2019-11-26 09:27:37
问题 Is it possible to access post or get parameters via the HttpActionContext object? I have a set of sensors that loggs data to a web server that provides a REST api. I would like to introduce some sort of authentication/authorization by letting the sensors include their hardware id in the data and then make a lookup in a database to see if the id exists or not. Since the API provides many web api action methods I would ideally like to use a custom authorization attribute public class

ASP.NET MVC Authorization

本秂侑毒 提交于 2019-11-26 09:27:14
问题 How do I achieve authorization with MVC asp.net? 回答1: Use the Authorize attribute [Authorize] public ActionResult MyAction() { //stuff } You can also use this on the controller. Can pass in users or roles too. If you want something with a little more control, you could try something like this. public class CustomAuthorizeAttribute : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) { string[] users = Users.Split(','); if (!httpContext.User.Identity

How is OAuth 2 different from OAuth 1?

一曲冷凌霜 提交于 2019-11-26 09:18:29
In very simple terms, can someone explain the difference between OAuth 2 and OAuth 1? Is OAuth 1 obsolete now? Should we be implementing OAuth 2? I don't see many implementations of OAuth 2; most are still using OAuth 1, which makes me doubt OAuth 2 is ready to use. Is it? villecoder Eran Hammer-Lahav has done an excellent job in explaining the majority of the differences in his article Introducing OAuth 2.0 . To summarize, here are the key differences: More OAuth Flows to allow better support for non-browser based applications. This is a main criticism against OAuth from client applications

HttpClient single instance with different authentication headers

穿精又带淫゛_ 提交于 2019-11-26 09:17:47
问题 Given that the .net HttpClient has been designed with reuse in mind and is intended to be long lived and memory leaks have been reported in short lived instances. What guide lines are there where you want to make restful calls to a given endpoint using different bearer tokens (or any authorization header) when calling the endpoint for multiple users? private void CallEndpoint(string resourceId, string bearerToken) { httpClient.DefaultRequestHeaders.Authorization = new

Authentication versus Authorization

≡放荡痞女 提交于 2019-11-26 09:06:54
What's the difference in context of web applications? I see the abbreviation "auth" a lot. Does it stand for auth -entication or auth -orization? Or is it both? Kerrek SB Authentication is the process of ascertaining that somebody really is who they claim to be. Authorization refers to rules that determine who is allowed to do what. E.g. Adam may be authorized to create and delete databases, while Usama is only authorised to read. The two concepts are completely orthogonal and independent, but both are central to security design, and the failure to get either one correct opens up the avenue to