Comments (3)
Yes, that's true. However, I am not sure there is possible to put a quick fix for that. If the client does not send an authorization header, the Hawk filter must return a challenge. The check about AllowAnonymous is performed later in the pipeline. The message handler does not even have access to the api method via reflection to get those attributes. What you can do is to configure the HawkMessagehandler for certain routes as I did here in this post,
http://weblogs.asp.net/cibrax/archive/2013/02/25/message-handlers-per-route-in-asp-net-web-api.aspx
I will remove that example with AllowAnonymous as it is broken as you said.
Thanks
Pablo.
from hawknet.
Well, actually, after I posted the above I started to dig a bit more and found a way to solve (at least on my project, but it should work on this too). Basically, what I'm doing is the following:
- In the SendAsync method, I first check if I have an Authorization header and if Scheme matches my scheme. If so, goto 2 else goto 3 :)
- Get a principal based on the request headers (here it is up to the implementation)
- return a base.SendAsync, but use a continuation (ContinueWith) and check if the result.StatusCode of the continuation is Unauthorized and if the Authorization is null or the Scheme is null or empty. In that case, send the challenge.
So later, the Authorize attribute on the action will check for an authorized principal and if it is not, it will return an Unauthorized response that will be catch'ed by the continuation.
I already have that implemented and it seems to be working fine.
from hawknet.
I found a way to fix this issue. The challenge is only returned when the upper layer returns Unauthorized. It's in the latest version. Thanks
from hawknet.
Related Issues (20)
- normalized string formatting in CalculateMac()
- Timing oracle that is likely exploitable to forge MACs
- Time units mismatch HOT 9
- HttpRequestMessageExtensionsTests.cs appears to be missing from HawkNet.WebApi.Tests.csproj HOT 1
- Post Not Returning Response
- Owin hosting non standard port and bad mac HOT 11
- Query string encoding bug HOT 2
- I download the simple,and run Example project,First client request and response "Bad mac" HOT 1
- uri.PathAndQuery.ToLower() is not working and return "Bad mac" HOT 1
- Not working with attribute routing HOT 5
- Problems validating bewit when url contains spaces encoded as %20 HOT 4
- Consider separating the Hawk implementation from the Web API plumbing HOT 2
- Exception: The format of value '<null>' is invalid
- About HawkNet on Asp.Net Core 2.0 HOT 2
- standard mismatch: ext-parameter shall be placed before mac-parameter
- httprequest depreciation - Later ASP.Net Core versions and httpclient
- timestampskew issue
- utf8 encoding vs ascii HOT 1
- payload hash formatting missing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hawknet.