/usr/include/Poco/Net/OAuth20Credentials.h is in libpoco-dev 1.8.0.1-1ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | //
// OAuth20Credentials.h
//
// Library: Net
// Package: OAuth
// Module: OAuth20Credentials
//
// Definition of the OAuth20Credentials class.
//
// Copyright (c) 2014, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Net_OAuth20Credentials_INCLUDED
#define Net_OAuth20Credentials_INCLUDED
#include "Poco/Net/Net.h"
namespace Poco {
namespace Net {
class HTTPRequest;
class Net_API OAuth20Credentials
/// This class implements OAuth 2.0 authentication for HTTP requests,
/// via Bearer tokens in the Authorization header,
/// according to RFC 6749 and RFC 6750.
///
/// To add an Authorization header containing a bearer token
/// to a HTTPRequest object, create an OAuth20Credentials object
/// with the bearer token and call authenticate().
///
/// The bearer token can also be extracted from a HTTPRequest
/// by creating the OAuth20Credentials object with a HTTPRequest
/// object containing a "Bearer" Authorization header and
/// calling getBearerToken().
///
/// The authorization header scheme can be changed from
/// "Bearer" to a custom value. For example, GitHub uses
/// the "token" scheme.
{
public:
OAuth20Credentials();
/// Creates an empty OAuth20Credentials object.
explicit OAuth20Credentials(const std::string& bearerToken);
/// Creates an OAuth20Credentials object with the given bearer token.
OAuth20Credentials(const std::string& bearerToken, const std::string& scheme);
/// Creates an OAuth20Credentials object with the given bearer token
/// and authorization scheme, which overrides the default scheme ("Bearer").
///
/// This is useful for services like GitHub, which use "token" as scheme.
explicit OAuth20Credentials(const HTTPRequest& request);
/// Creates an OAuth20Credentials object from a HTTPRequest object.
///
/// Extracts bearer token from the Authorization header, which
/// must use the "Bearer" authorization scheme.
///
/// Throws a NotAuthenticatedException if the request does
/// not contain a bearer token in the Authorization header.
OAuth20Credentials(const HTTPRequest& request, const std::string& scheme);
/// Creates an OAuth20Credentials object from a HTTPRequest object.
///
/// Extracts bearer token from the Authorization header, which must
/// use the given authorization scheme.
///
/// Throws a NotAuthenticatedException if the request does
/// not contain a bearer token in the Authorization header.
~OAuth20Credentials();
/// Destroys the HTTPCredentials.
void setBearerToken(const std::string& bearerToken);
/// Sets the bearer token.
const std::string& getBearerToken() const;
/// Returns the bearer token.
void setScheme(const std::string& scheme);
/// Sets the Authorization header scheme.
const std::string& getScheme() const;
/// Returns the Authorization header scheme.
void authenticate(HTTPRequest& request);
/// Adds an Authorization header containing the bearer token to
/// the HTTPRequest.
static const std::string SCHEME;
protected:
void extractBearerToken(const HTTPRequest& request);
/// Extracts the bearer token from the HTTPRequest.
private:
OAuth20Credentials(const OAuth20Credentials&);
OAuth20Credentials& operator = (const OAuth20Credentials&);
std::string _bearerToken;
std::string _scheme;
};
//
// inlines
//
inline const std::string& OAuth20Credentials::getBearerToken() const
{
return _bearerToken;
}
inline const std::string& OAuth20Credentials::getScheme() const
{
return _scheme;
}
} } // namespace Poco::Net
#endif // Net_OAuth20Credentials_INCLUDED
|