authorization

How to get http headers in flask?

女生的网名这么多〃 提交于 2019-11-28 17:41:15
I am newbie to python and using Python Flask and generating REST API service. I want to check authorization header which is sent the client. But I can't find way to get HTTP header in flask. Any help for getting HTTP header authorization is appreciated. from flask import request request.headers.get('your-header-name') request.headers behaves like a dictionary, so you can also get your header like you would with any dictionary: request.headers['your-header-name'] just note, The different between the methods are, if the header is not exist request.headers.get('your-header-name') will return None

Should I be using an IAuthorizationFilter if I wish to create an ApiKey restricted resource with ASP.NET MVC4?

时间秒杀一切 提交于 2019-11-28 17:35:15
I have a few simple routes which I wish to restrict via a simple querystring param. If the key is incorrect or not provided, then I wish to throw a NotAuthorizedException . Please don't suggest I use WebApi or the equiv - I can't just yet in this scenario. So i'm not sure if I should be implementing an IAuthorizationFilter or implementing an IActionFilter or even something else. My code logic? Check querystring for key. Check my RavenDb (repository) for a user with that key/value. If they fail any of those checks, then throw the NotAuthorizedException . I'm assuming I would then decorate a my

How to securely authorize a user via Facebook's Javascript SDK

扶醉桌前 提交于 2019-11-28 17:29:51
I want to let users log in on my website using their Facebook ID without reloading the page. This is why I use Facebook Javascript SDK . This scheme describes the authorization flow with this SDK: At the end of the process I know that the user is logged in and I know their Facebook ID. I can then register them in my database via this ID, and let them use it to log in afterwards. However, this seems terribly insecure. In order to let my server-side script know the user's ID, I have to send it via AJAX. However, I have no way of knowing whether it's the owner of the ID who's trying to log in.

Redirect Unauthorized Page Access in MVC to Custom View

空扰寡人 提交于 2019-11-28 17:14:06
问题 I have an MVC website in which access is based on various Roles. Once a user logs into the system they can see navigation to the pages for which they are authorized. However, some users may still try to access pages using a direct URL. If they do, the system automatically redirects them to the Login Page. Instead of the Login Page I want to redirect them to another view (Unauthorized). Web.Config has the following entry: <customErrors mode="On"> <error statusCode="401" redirect="~/Home

MVC Custom Authentication, Authorization, and Roles Implementation

六月ゝ 毕业季﹏ 提交于 2019-11-28 17:06:34
Bear with me as I provide details for the issue... I've got an MVC site, using FormsAuthentication and custom service classes for Authentication, Authorization, Roles/Membership, etc. Authentication There are three ways to sign-on: (1) Email + Alias , (2) OpenID , and (3) Username + Password . All three get the user an auth cookie and start a session. The first two are used by visitors (session only) and the third for authors/admin with db accounts. public class BaseFormsAuthenticationService : IAuthenticationService { // Disperse auth cookie and store user session info. public virtual void

MVC 3 dynamic authorization of multiple roles and users

感情迁移 提交于 2019-11-28 16:54:07
I recently starded developing for MVC 3 but have experience in both C# and ASP.NET since earlier. So i'll start with what i'm trying to accomplish. I've developed a small site for hosting articles. I've implemented SQLServer based membership managament to the site. Now i want to create a credentials system that restricts and allows the right users to create, delete and update articles. There is one simple solution to this and that is to do it like this: [Authorize(Roles="Admin")] public ActionResult UpdateArticle(ArticleModel model, int articleid) { return View(); } Now this is really simple.

Google Cloud Endpoints limitations… any proposed solutions?

允我心安 提交于 2019-11-28 16:48:49
Am I correct in thinking that the goodness of Cloud Endpoints comes with the following limitations: The REST Api cannot be deployed to a custom domain (it'll remain on appspot.com). The only authentication supported is OAuth against Google accounts. Corollary: it isn't currently possible to create a user login/session-tracking mechanism that is Google-accounts-agnostic (e.g., with email as username and a password). Is there any plan to do away with these limitations and if so, what is the ETA? Taking these item by item: Currently, yes this is still the case. Keep in mind, our initial release

React Router Authorization

♀尐吖头ヾ 提交于 2019-11-28 16:48:13
What are the best practices for authorization checking prior to a component mounting? I use react-router 1.x Here are my routes React.render(( <Router history={History.createHistory()}> <Route path="/" component={Dashboard}></Route> <Route path="/login" component={LoginForm}></Route> </Router> ), document.body); Here is my Dashboard component: var Dashboard = React.createClass({ componentWillMount: function () { // I want to check authorization here // If the user is not authorized they should be redirected to the login page. // What is the right way to perform this check? }, render: function

How to define the basic HTTP authentication using cURL correctly?

谁都会走 提交于 2019-11-28 16:36:18
I'm learning Apigility ( Apigility docu -> REST Service Tutorial ) and trying to send a POST request with basic authentication via cURL: $ curl -X POST -i -H "Content-Type: application/hal+json" -H "Authorization: Basic YXBpdXNlcjphcGlwd2Q=" http://apigilityhw.sandbox.loc/status YXBpdXNlcjphcGlwd2Q= is the base 64 encoded string with my credentials apiuser:apipwd . The credentials are saved in the /data/htpasswd ( apiuser:$apr1$3J4cyqEw$WKga3rQMkxvnevMuBaekg/ ). The looks like this: HTTP/1.1 401 Unauthorized Server: nginx/1.4.7 Date: Mon, 22 Sep 2014 07:48:47 GMT Content-Type: application

Why is <deny users=“?” /> included in the following example?

瘦欲@ 提交于 2019-11-28 16:28:32
The ? wildcard represents unauthenticated users while * represents all users, authenticated and unauthenticated. My book shows the following example of URL authorization: <authorization> <deny users="?" /> <allow users="dan,matthew" /> <deny users="*" /> </authorization> But doesn’t the above code have the same effect as : <authorization> <allow users="dan,matthew" /> <deny users="*" /> </authorization> or did the author also include <deny users="?" /> rule for a reason? Cyberherbalist ASP.NET grants access from the configuration file as a matter of precedence. In case of a potential conflict,