HaikuDepot: Token Based Authentication

This switches the application over from using basic
authentication to using token-based authentication in
preparation for later using Open-ID based
authentication flows. The application version is also
bumped in order that the server can detect this version
at some later date in the future when it no longer
supports basic authentication itself.

Change-Id: I7addde1d57503c58d6bcd54908f22f66830c0c59
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6944
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
Andrew Lindesay
2023-09-25 06:20:32 +00:00
parent d8bca3564a
commit 4b347fccb2
31 changed files with 1103 additions and 160 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2014 Haiku Inc. All rights reserved.
* Copyright 2010-2023 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _B_HTTP_AUTHENTICATION_H_
@@ -24,8 +24,10 @@ enum BHttpAuthenticationMethod {
// Basic base64 authentication method (unsecure)
B_HTTP_AUTHENTICATION_DIGEST = 2,
// Digest authentication
B_HTTP_AUTHENTICATION_IE_DIGEST = 4
B_HTTP_AUTHENTICATION_IE_DIGEST = 4,
// Slightly modified digest authentication to mimic old IE one
B_HTTP_AUTHENTICATION_BEARER = 5
// Bearer authentication used to convey a token
};
@@ -56,6 +58,7 @@ public:
// Field modification
void SetUserName(const BString& username);
void SetPassword(const BString& password);
void SetToken(const BString& token);
void SetMethod(
BHttpAuthenticationMethod type);
status_t Initialize(const BString& wwwAuthenticate);
@@ -63,6 +66,7 @@ public:
// Field access
const BString& UserName() const;
const BString& Password() const;
const BString& Token() const;
BHttpAuthenticationMethod Method() const;
BString Authorization(const BUrl& url,
@@ -89,6 +93,7 @@ private:
BHttpAuthenticationMethod fAuthenticationMethod;
BString fUserName;
BString fPassword;
BString fToken;
BString fRealm;
BString fDigestNonce;