Completed
Push — master ( 6e52f0...d9a404 )
by Alexandre
02:29
created

ConfidentialClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 73
rs 10
c 0
b 0
f 0
ccs 0
cts 14
cp 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPassword() 0 3 1
A setPassword() 0 3 1
A supportHTTPBasicAuthenticationScheme() 0 2 1
A hasCredentials() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 30/12/2017
6
 * Time: 18:42
7
 */
8
9
namespace OAuth2OLD\Role\Client\Type;
10
11
use OAuth2OLD\Role\Client\RegisteredClient;
12
13
14
/**
15
 * Class ClientPassword
16
 * @package OAuth2\roles\clients
17
 *
18
 * @see https://tools.ietf.org/html/rfc6749#section-2.1
19
 *
20
 * Client Types
21
 *
22
 *     Clients capable of maintaining the confidentiality of their
23
 * credentials (e.g., client implemented on a secure server with
24
 * restricted access to the client credentials), or capable of secure
25
 * client authentication using other means.
26
 *
27
 *
28
 * @see https://tools.ietf.org/html/rfc6749#section-2.3
29
 *
30
 * Client Authentication
31
 *
32
 *     If the client type is confidential, the client and authorization
33
 * server establish a client authentication method suitable for the
34
 * security requirements of the authorization server.  The authorization
35
 * server MAY accept any form of client authentication meeting its
36
 * security requirements.
37
 *
38
 * Confidential clients are typically issued (or establish) a set of
39
 * client credentials used for authenticating with the authorization
40
 * server (e.g., password, public/private key pair).
41
 *
42
 * The authorization server MAY establish a client authentication method
43
 * with public clients.  However, the authorization server MUST NOT rely
44
 * on public client authentication for the purpose of identifying the
45
 * client.
46
 *
47
 * The client MUST NOT use more than one authentication method in each
48
 * request.
49
 */
50
abstract class ConfidentialClient extends RegisteredClient implements ClientTypeInterface
51
{
52
    /**
53
     * @var string
54
     *
55
     * @see https://tools.ietf.org/html/rfc6749#section-2.3.1
56
     *
57
     * Client Password
58
     *
59
     *     Clients in possession of a client password MAY use the HTTP Basic
60
     * authentication scheme as defined in [RFC2617] to authenticate with
61
     * the authorization server.  The client identifier is encoded using the
62
     * "application/x-www-form-urlencoded" encoding algorithm per
63
     * Appendix B, and the encoded value is used as the username; the client
64
     * password is encoded using the same algorithm and used as the
65
     * password.  The authorization server MUST support the HTTP Basic
66
     * authentication scheme for authenticating clients that were issued a
67
     * client password.
68
     *
69
     * For example (with extra line breaks for display purposes only):
70
     *
71
     * Authorization: Basic czZCaGRSa3F0Mzo3RmpmcDBaQnIxS3REUmJuZlZkbUl3
72
     *
73
     * Alternatively, the authorization server MAY support including the
74
     * client credentials in the request-body using the following parameters:
75
     *
76
     * client_id
77
     * REQUIRED.  The client identifier issued to the client during
78
     * the registration process described by Section 2.2.
79
     *
80
     * client_secret
81
     * REQUIRED.  The client secret.  The client MAY omit the
82
     * parameter if the client secret is an empty string.
83
     *
84
     * Including the client credentials in the request-body using the two
85
     * parameters is NOT RECOMMENDED and SHOULD be limited to clients unable
86
     * to directly utilize the HTTP Basic authentication scheme (or other
87
     * password-based HTTP authentication schemes).  The parameters can only
88
     * be transmitted in the request-body and MUST NOT be included in the
89
     * request URI.
90
     *
91
     * The authorization server MUST require the use of TLS as described in
92
     * Section 1.6 when sending requests using password authentication.
93
     *
94
     * Since this client authentication method involves a password, the
95
     * authorization server MUST protect any endpoint utilizing it against
96
     * brute force attacks.
97
     */
98
    protected $password;
99
100
    /**
101
     * @return string
102
     */
103
    public function getPassword(): string
104
    {
105
        return $this->password;
106
    }
107
108
    /**
109
     * @param string $password
110
     */
111
    public function setPassword(string $password): void
112
    {
113
        $this->password = $password;
114
    }
115
116
    public function hasCredentials(): bool
117
    {
118
        return true;
119
    }
120
121
    public function supportHTTPBasicAuthenticationScheme() : bool {
122
        return true;
123
    }
124
}