News for hackers. Stuff that matters.
Re:Authentication and the Have I Been Pwned API by theandrewbailey on Friday July 19, 2019 @12:42PM (#20480181)
> Making an authenticated call is a piece of cake, you just add an hibp-api-key header as follows:

> GET https://haveibeenpwned.com/api/v3/breachedaccount/test@examp...

> hibp-api-key: [your key]

Wouldn't the standard Authorization: Bearer <key> header be more compliant?

Re:Authentication and the Have I Been Pwned API by floatingatoll on Friday July 19, 2019 @02:08PM (#20481055)
See also elsethread about "not a token" — but, also:

> There's a couple of these and they're largely due to me trying to make sure I get this feature out as early as possible and continue to run things on a shoestring cost wise

Using the Authorization header can cause significant problems with both clients and servers, and also might unintentionally permit browsers to directly query the server if they can be convinced to provide a bearer token.

Using a custom HTTP header sidesteps both client and server issues altogether and closes the door on browsers direct-querying the API, which could be considered a positive by the site operator.

Re:Authentication and the Have I Been Pwned API by theandrewbailey on Friday July 19, 2019 @03:42PM (#20481816)
I'm not sure how browsers using the API would be a concern. Someone paid for the key, so it should be up to them to use it how they please (within rate limits).
Re:Authentication and the Have I Been Pwned API by floatingatoll on Friday July 19, 2019 @05:04PM (#20482421)
Allowing browsers to query directly would break the terms of engagement specified by the site operator, who specified that a proxy shall be used to concentrate end-user requests for a given paid key. That’s their right as service operator. I can construct plausible scenarios why this is a sensible choice, but the underlying point is that they clearly regardless made that choice after thinking it through.
Re:Authentication and the Have I Been Pwned API by akerl_ on Friday July 19, 2019 @05:50PM (#20482731)
That’s not a requirement specified anywhere. The “Protecting the API Key“ section talks about using a proxy specifically in the context of client-side applications (think of things like 1Password that integrate w/ HIBP), where embedding the API key into the app is obviously undesirable. In those cases, using a proxy allows managing the request volume and injecting the API key.

That same section of the document describes other scenarios, like a hosted service or a CLI tool, that do not involve a proxy service.

Re:Authentication and the Have I Been Pwned API by floatingatoll on Friday July 19, 2019 @06:04PM (#20482830)
I look forward to clarification someday from the operator - but that custom header will still block non-extension browser-side calls in v3, and I bet the ACAO header isn’t present to allow it either.
Re:Authentication and the Have I Been Pwned API by pionar on Friday July 19, 2019 @02:00PM (#20480976)
No, because it's not a bearer token.

Edit for clarity: A bearer token [0] is a concept for OAuth. This is not OAuth.

[0] https://tools.ietf.org/html/rfc6750#section-1.2

Re:Authentication and the Have I Been Pwned API by Androider on Friday July 19, 2019 @02:15PM (#20481115)
OAuth doesn't have a monopoly on bearer tokens. And it is literally the definition of a bearer token: you shall know the messenger who presents this token, a concept old as history itself.
Re:Authentication and the Have I Been Pwned API by y4mi on Friday July 19, 2019 @02:22PM (#20481168)
Should every OS which uses windows be able to call itself Windows, because windows are a quite old thing as well?

Like it or not, there is an rfc for this and using it for anything else would be code smell at best

Re:Authentication and the Have I Been Pwned API by patmorgan23 on Friday July 19, 2019 @02:44PM (#20481379)
> Should every OS which uses windows be able to call itself Windows, because windows are a quite old thing as well?

> Like it or not, there is an rfc for this and using it for anything else would be code smell at best

No but every OS that uses windows can call them windows....

Re:Authentication and the Have I Been Pwned API by y4mi on Friday July 19, 2019 @03:16PM (#20481636)
I guess they should be able to call them windows.

Can you link to any tool which uses bearer tokens and doesn't grant them through oauth2?

Or it's internal, please explain how the token is obtained.

I haven't seen any to date but I guess I could be wrong

Re:Authentication and the Have I Been Pwned API by X-Istence on Friday July 19, 2019 @04:17PM (#20482081)
Github will happily hand you an access token by visiting "https://github.com/settings/tokens".

These are bearer tokens, in that the bearer gets granted access by that token alone.

You happen to send it along in a Basic authentication in HTTP instead of as an Authorization header, but it is a bearer token all the same.

No OAuth2 flow required.

Re:Authentication and the Have I Been Pwned API by X-Istence on Friday July 19, 2019 @04:20PM (#20482101)
Any service that uses API keys are basically handing out bearer tokens. Whoever holds that API key can make requests to the service, it grants you access.
Re:Authentication and the Have I Been Pwned API by OJFord on Friday July 19, 2019 @07:01PM (#20483136)
> Can you link to any tool which uses bearer tokens and doesn't grant them through oauth2?

Yes: https://www.pelion.com/docs/device-management/current/integr...

(I know I've seen and used many others, but Pelion comes first to mind because I used to work on it.)

Re:Authentication and the Have I Been Pwned API by Androider on Friday July 19, 2019 @09:08PM (#20483612)
It's incredibly common. See Stripe for example https://stripe.com/docs/api/authentication

Authorization: Bearer <API Key>.

Re:Authentication and the Have I Been Pwned API by theandrewbailey on Friday July 19, 2019 @02:23PM (#20481183)
JWT uses Authorization: Bearer, too.

https://jwt.io/introduction/