GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 310b67...f3cbc4 )
by Damien
16:56 queued 13:08
created

Saml::getAuthnRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: dsmrt
5
 * Date: 1/9/18
6
 * Time: 9:11 AM
7
 */
8
9
namespace flipbox\saml\idp;
10
11
use craft\events\RegisterComponentTypesEvent;
12
use craft\services\Fields;
13
use craft\web\UrlManager;
14
use craft\web\User;
15
use flipbox\saml\core\AbstractPlugin;
16
use flipbox\saml\core\containers\Saml2Container;
17
use flipbox\saml\core\models\SettingsInterface;
18
use flipbox\saml\idp\fields\ExternalIdentity;
19
use flipbox\saml\idp\models\Settings;
20
use flipbox\saml\idp\records\ProviderIdentityRecord;
21
use flipbox\saml\idp\records\ProviderRecord;
22
use flipbox\saml\idp\services\messages\AuthnRequest;
23
use flipbox\saml\idp\services\messages\Response;
24
use flipbox\saml\idp\services\messages\ResponseAssertion;
25
use flipbox\saml\idp\services\Provider;
26
use flipbox\saml\idp\services\ProviderIdentity;
27
use flipbox\saml\idp\services\Session;
28
use SAML2\Compat\AbstractContainer;
29
use yii\base\Event;
30
31
class Saml extends AbstractPlugin
32
{
33
34 38
    public function init()
35
    {
36 38
        parent::init();
37
38 38
        $this->initCore();
39 38
        $this->initComponents();
40 38
        $this->initEvents();
41 38
    }
42
43 38
    public function initComponents()
44
    {
45 38
        $this->setComponents([
46 38
            'authnRequest' => AuthnRequest::class,
47
            'provider' => Provider::class,
48
            'providerIdentity' => ProviderIdentity::class,
49
            'response' => Response::class,
50
            'responseAssertion' => ResponseAssertion::class,
51
            'session' => Session::class,
52
        ]);
53 38
    }
54
55
    /**
56
     * Init events
57
     */
58 38
    public function initEvents()
59
    {
60
        /**
61
         * After login
62
         */
63 38
        Event::on(
64 38
            User::class,
65 38
            User::EVENT_AFTER_LOGIN,
66
            [
67 38
                $this->getResponse(),
68 38
                'createAndSendFromSession',
69
            ]
70
        );
71
72
        /**
73
         * CP routes
74
         */
75 38
        Event::on(
76 38
            UrlManager::class,
77 38
            UrlManager::EVENT_REGISTER_CP_URL_RULES,
78 38
            [self::class, 'onRegisterCpUrlRules']
79
        );
80
81
        /**
82
         * Clean Frontend Endpoints
83
         */
84 38
        Event::on(
85 38
            UrlManager::class,
86 38
            UrlManager::EVENT_REGISTER_SITE_URL_RULES,
87 38
            [static::class, 'onRegisterSiteUrlRules']
88
        );
89
90 38
        Event::on(
91 38
            Fields::class,
92 38
            Fields::EVENT_REGISTER_FIELD_TYPES,
93
            function (RegisterComponentTypesEvent $event) {
94
                $event->types[] = ExternalIdentity::class;
95 38
            }
96
        );
97 38
    }
98
99
    /**
100
     * @return Settings
101
     */
102 16
    public function getSettings(): SettingsInterface
103
    {
104 16
        return parent::getSettings();
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::getSettings() returns the type craft\base\Model|null which is incompatible with the type-hinted return flipbox\saml\core\models\SettingsInterface.
Loading history...
105
    }
106
107
    /**
108
     * @inheritdoc
109
     */
110 18
    public function createSettingsModel()
111
    {
112 18
        return new Settings([
113 18
            'myType' => SettingsInterface::IDP,
114
        ]);
115
    }
116
117
    /**
118
     * Components
119
     */
120
121
    /**
122
     * @return AuthnRequest
123
     */
124 4
    public function getAuthnRequest()
125
    {
126 4
        return $this->get('authnRequest');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('authnRequest') also could return the type mixed which is incompatible with the documented return type flipbox\saml\idp\services\messages\AuthnRequest.
Loading history...
127
    }
128
129
    /**
130
     * @return Response
131
     */
132 38
    public function getResponse()
133
    {
134 38
        return $this->get('response');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('response') also could return the type mixed which is incompatible with the documented return type flipbox\saml\idp\services\messages\Response.
Loading history...
135
    }
136
137
    /**
138
     * @return ResponseAssertion
139
     */
140 4
    public function getResponseAssertion()
141
    {
142 4
        return $this->get('responseAssertion');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('responseAssertion') also could return the type mixed which is incompatible with the documented return type flipbox\saml\idp\service...sages\ResponseAssertion.
Loading history...
143
    }
144
145
    /**
146
     * @return Session
147
     */
148 10
    public function getSession()
149
    {
150 10
        return $this->get('session');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('session') also could return the type mixed which is incompatible with the documented return type flipbox\saml\idp\services\Session.
Loading history...
151
    }
152
153
    /**
154
     * Util Methods
155
     */
156
157
    /**
158
     * @return string
159
     */
160 10
    public function getProviderRecordClass()
161
    {
162 10
        return ProviderRecord::class;
163
    }
164
165
    /**
166
     * @return string
167
     */
168 2
    public function getProviderIdentityRecordClass()
169
    {
170 2
        return ProviderIdentityRecord::class;
171
    }
172
173
    /**
174
     * @return Saml2Container
175
     */
176 4
    public function loadSaml2Container(): AbstractContainer
177
    {
178 4
        $container = new Saml2Container($this);
179
180 4
        \SAML2\Compat\ContainerSingleton::setContainer($container);
181
182 4
        return $container;
183
    }
184
}
185