bearer-token

SignalR authentication failed when passing “Bearer” through query string

六眼飞鱼酱① 提交于 2019-12-03 15:21:20
I'd like to enable authentication in SignalR while the server was hosted in ASP.NET WebAPI which I'm using OAuth Bearer authrntication and the client is AngularJS. On client side I originally pass the Bearer token through HTTP header and it works well with the WebAPI. But since SignalR JavsScript doesn't support adding HTTP headers in connection (it's because WebSocket doesn't support specifying HTTP headers) I need to pass the Bearer token through query string by using the code like self.connection.qs = { Bearer: 'xxxxxx' }; The problem is on the WebAPI side my SignalR always returned 401

Why should you base64 encode the Authorization header?

夙愿已清 提交于 2019-12-03 14:00:31
Twitter's API requires sending an Authorization header that is a base64 encoding of an API key concatenated with an API secret key. In Node, I use: var base64 = new Buffer(apiKey + ':' + apiSecret).toString('base64'); The header sent becomes: Authorization: 'Basic ' + base64 What is the point of base64 encoding the string "apiKeyHere:apiSecretHere"? Why not just accept an Authorization header containing the raw api credentials? This question is similar to What is the purpose of base 64 encoding and why it used in HTTP Basic Authentication? but the voted answer doesn't fully answer my question.

OAuth Bearer Access Token sliding expiration

痴心易碎 提交于 2019-12-03 08:17:26
Let's suppose that we're using OAuth Bearer tokens to secure our API. There is NuGet package with OWIN middleware that will do it for us: https://www.nuget.org/packages/Microsoft.Owin.Security.OAuth . Everethig looks great, until raises question about access token expiration - we don't want to force use to re-login over and over again. As far as I understand there are three basic ways: Make Access Token expiration time very big (1 month for instance) Use OAuth Refresh Tokens that adds much difficulties to both Authentication Server and the user application code (described in following article

OWIN Bearer Token Authentication

无人久伴 提交于 2019-12-03 07:20:19
问题 I have some questions related to Bearer Token. In Owin you can protect a ticket Protect(ticket) like this: ClaimsIdentity identity = new ClaimsIdentity(Startup.OAuthServerOptions.AuthenticationType); identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName)); Dictionary<string, string> properties = new Dictionary<string, string>(); properties.Add("UserId", user.Id); properties.Add("UserName", user.UserName); properties.Add("Role", "user"); AuthenticationProperties properties = new

Adding additional logic to Bearer authorization

醉酒当歌 提交于 2019-12-03 02:26:08
问题 I am attempting to implement OWIN bearer token authorization, and based on this article. However, there's one additional piece of information I need in bearer token that I don't know how to implement. In my application, I need to deduce from the bearer token user information (say userid). This is important because I don't want an authorized user from being able to act as another user. Is this doable? Is it even the correct approach? If the userid is a guid, then this would be simple. It's an

OWIN Bearer Token Authentication

廉价感情. 提交于 2019-12-02 20:51:26
I have some questions related to Bearer Token. In Owin you can protect a ticket Protect(ticket) like this: ClaimsIdentity identity = new ClaimsIdentity(Startup.OAuthServerOptions.AuthenticationType); identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName)); Dictionary<string, string> properties = new Dictionary<string, string>(); properties.Add("UserId", user.Id); properties.Add("UserName", user.UserName); properties.Add("Role", "user"); AuthenticationProperties properties = new AuthenticationProperties(properties); AuthenticationTicket ticket = new AuthenticationTicket(identity,

Authorization bearer token Angular 5

旧时模样 提交于 2019-12-02 20:36:54
I am confused about how to create a good header for a simple Get request in Angular 5. This is what I need to do in Angular: This is what I have so far: getUserList(): Observable<UserList[]> { const headers = new Headers(); let tokenParse = JSON.parse(this.token) headers.append('Authorization', `Bearer ${tokenParse}`); const opts = new RequestOptions({ headers: headers }); console.log(JSON.stringify(opts)); const users = this.http.get<UserList[]>(this.mainUrl, opts) return users .catch(this.handleError.handleError); } This is the response in my console.log: {"method":null,"headers":{

Adding additional logic to Bearer authorization

喜你入骨 提交于 2019-12-02 17:21:58
I am attempting to implement OWIN bearer token authorization, and based on this article . However, there's one additional piece of information I need in bearer token that I don't know how to implement. In my application, I need to deduce from the bearer token user information (say userid). This is important because I don't want an authorized user from being able to act as another user. Is this doable? Is it even the correct approach? If the userid is a guid, then this would be simple. It's an integer in this case. An authorized user can potentially impersonate another just by guessing / brute

asp.net identity expire bearer token after 20 min

泄露秘密 提交于 2019-12-02 06:00:38
问题 i have a web service, users can login to service and give bearer token. in local everything is good, but in server (shared host, windows 2012, iis 8.5) after 20 min, token has been expired !!! my AccessTokenExpireTimeSpan is : AccessTokenExpireTimeSpan = TimeSpan.FromDays(900), also in my first request, i give a delay about 5 sec. what is problem ? 回答1: I asume that you in production have multiple servers. And ASP.NET Identity is using the server's machine key to generate the token bearer. So

How to add a “Authorization=Bearer” header with Indy in Delphi?

北城余情 提交于 2019-12-01 10:58:29
I'm trying to do a POST request using an access_token, and it works fine using POSTMAN, but when I try to do the same request on Delphi, I can't find a way to add the "Authorization=Bearer eyxxxxxx..." to the Request header, as POSTMAN does. POSTMAN Request (working well): POST /somepath HTTP/1.1 Host: someurl.com.br Authorization: Bearer eyJhbGciOiJSUzI1NiJ9..... Content-Type: application/json (body content ommited) Indy Request generated by Delphi, captured by HTTP Analyzer (always returning 401 Forbidden error, because the absence of "Authorization=Bearer" part): POST /somepath HTTP/1.1