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.

Saml::getSettings()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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