AuthorizationServer   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 69
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getAuthorizationEndpoint() 0 3 1
A isSecure() 0 3 3
A getTokenEndpoint() 0 3 1
A getTokenRevocationEndpoint() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 10/03/2018
6
 * Time: 15:55
7
 */
8
9
namespace OAuth2\Roles\AuthorizationServer;
10
11
use OAuth2\Endpoints\AuthorizationEndpoint;
12
use OAuth2\Endpoints\EndpointInterface;
13
use OAuth2\Endpoints\TokenEndpoint;
14
use OAuth2\Endpoints\TokenRevocationEndpoint;
15
use OAuth2\Roles\AuthorizationServerInterface;
16
17
18
class AuthorizationServer implements AuthorizationServerInterface
19
{
20
    protected $authorizationEndpoint;
21
    protected $tokenEndpoint;
22
    protected $tokenRevocationEndpoint;
23
24
    public function __construct(AuthorizationEndpoint $authorizationEndpoint,
25
                                TokenEndpoint $tokenEndpoint,
26
                                TokenRevocationEndpoint $tokenRevocationEndpoint)
27
    {
28
29
        $this->authorizationEndpoint = $authorizationEndpoint;
30
        $this->tokenEndpoint = $tokenEndpoint;
31
        $this->tokenRevocationEndpoint = $tokenRevocationEndpoint;
32
    }
33
34
    /**
35
     * @return AuthorizationEndpoint
36
     */
37
    public function getAuthorizationEndpoint(): EndpointInterface
38
    {
39
        return $this->authorizationEndpoint;
40
    }
41
42
    /**
43
     * @return TokenEndpoint
44
     */
45
    public function getTokenEndpoint(): EndpointInterface
46
    {
47
        return $this->tokenEndpoint;
48
    }
49
50
    /**
51
     * @return TokenRevocationEndpoint
52
     */
53
    public function getTokenRevocationEndpoint(): EndpointInterface
54
    {
55
        return $this->tokenRevocationEndpoint;
56
    }
57
58
    /**
59
     * @return bool
60
     *
61
     * @see https://tools.ietf.org/html/rfc6749#section-3.1.2.1
62
     *
63
     *  Endpoint Request Confidentiality
64
     *
65
     *     The redirection endpoint SHOULD require the use of TLS as described
66
     * in Section 1.6 when the requested response type is "code" or "token",
67
     * or when the redirection request will result in the transmission of
68
     * sensitive credentials over an open network.  This specification does
69
     * not mandate the use of TLS because at the time of this writing,
70
     * requiring clients to deploy TLS is a significant hurdle for many
71
     * client developers.  If TLS is not available, the authorization server
72
     * SHOULD warn the resource owner about the insecure endpoint prior to
73
     * redirection (e.g., display a message during the authorization
74
     * request).
75
     *
76
     * Lack of transport-layer security can have a severe impact on the
77
     * security of the client and the protected resources it is authorized
78
     * to access.  The use of transport-layer security is particularly
79
     * critical when the authorization process is used as a form of
80
     * delegated end-user authentication by the client (e.g., third-party
81
     * sign-in service).
82
     * @deprecated
83
     */
84
    public function isSecure()
85
    {
86
        return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443;
87
    }
88
}