blib/lib/Lemonldap/NG/Manager/Api.pm

filter: Statementstmt 100% 54 / 54 Branchbran n/a Conditioncond 71.4% 5 / 7 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 15 / 15 Podpod 0.0% 0 / 1 totaltotal 93.8% 76 / 81 CC 4 SCAR 5.2
CC
4
Cov
97%
init
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
« blib/lib/Lemonldap/NG/Manager/2ndFA.pm ↑ Summary blib/lib/Lemonldap/NG/Manager/Cli/Lib.pm »
1 # This module implements all the methods that responds to '/api/*' requests
2 package Lemonldap::NG::Manager::Api;
3  
4 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 28 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 28 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 28 ▶use Lemonldap::NG::Manager::Api::2F;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 28 ▶use Lemonldap::NG::Manager::Api::History;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 28 ▶use Lemonldap::NG::Manager::Api::Misc;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 28 ▶use Lemonldap::NG::Manager::Api::Providers::OidcRp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 28 ▶use Lemonldap::NG::Manager::Api::Providers::SamlSp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 28 ▶use Lemonldap::NG::Manager::Api::Providers::CasApp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 28 ▶use Lemonldap::NG::Manager::Api::Menu::Cat;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 28 ▶use Lemonldap::NG::Manager::Api::Menu::App;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 28 ▶use Lemonldap::NG::Common::TOTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 28 extends qw(
19 Lemonldap::NG::Manager::Plugin
20 Lemonldap::NG::Common::Conf::RESTServer
21 Lemonldap::NG::Common::Session::REST
22 );
23  
24 28 has totp_encrypt => ( is => "rw" );
25 28 our $VERSION = '2.19.0';
26  
27 #############################
28 # I. INITIALIZATION METHODS #
29 #############################
30  
31 28 ▶use constant defaultRoute => 'api.html';
Subroutine BEGIN: called CC=1 SCAR=0.0
32 28 ▶use constant icon => 'flash';
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 45 ▶sub init {
Subroutine init: called CC=4 SCAR=14.0
Pod undocumented
35 45 my ( $self, $conf ) = @_;
36  
37 45 $self->ua( Lemonldap::NG::Common::UserAgent->new($conf) );
38 $self->totp_encrypt(
39 Lemonldap::NG::Common::TOTP->new(
40 key => ( $conf->{totp2fKey} || $conf->{key} ),
41 encryptSecret => $conf->{totp2fEncryptSecret}
42 )
43 45 ▶ );
Condition100%3/3
$conf->{'totp2fKey'} || $conf->{'key'}
l!l&&r!l&&!r
4122
MC/DC100%2/2
$conf->{'totp2fKey'} || $conf->{'key'}
$conf->{'totp2fKey'} $conf->{'key'}
Truth table100%3/3
A || B
A= $conf->{'totp2fKey'}B= $conf->{'key'}
ABresult
1X1
011
000
44  
45 # HTML template
46 45 $self->addRoute( 'api.html', undef, ['GET'] )
47  
48 ->addRoute(
49 api => {
50 v1 => {
51 status => 'status',
52 providers => {
53 oidc => {
54 rp => {
55 findByConfKey => {
56 ':uPattern' => 'findOidcRpByConfKey'
57 },
58 findByClientId => {
59 ':uClientId' => 'findOidcRpByClientId'
60 },
61 ':confKey' => 'getOidcRpByConfKey'
62 },
63 },
64 saml => {
65 sp => {
66 findByConfKey => {
67 ':uPattern' => 'findSamlSpByConfKey'
68 },
69 findByEntityId => {
70 ':uEntityId' => 'findSamlSpByEntityId'
71 },
72 ':confKey' => 'getSamlSpByConfKey'
73 },
74 },
75 cas => {
76 app => {
77 findByConfKey => {
78 ':uPattern' => 'findCasAppByConfKey'
79 },
80 findByServiceUrl => {
81 ':uServiceUrl' => 'findCasAppsByServiceUrl'
82 },
83 ':confKey' => 'getCasAppByConfKey'
84 },
85 },
86 },
87 secondFactor => {
88 ':_uid' => {
89 id => {
90 ':id' => 'getSecondFactorsById'
91 },
92 type => {
93 ':type' => 'getSecondFactorsByType'
94 },
95 '*' => 'getSecondFactors'
96 },
97 },
98 menu => {
99 cat => {
100 findByConfKey => {
101 ':uPattern' => 'findMenuCatByConfKey'
102 },
103 ':confKey' => {
104 '*' => 'getMenuCatByConfKey'
105 }
106 },
107 app => {
108 ':confKey' => {
109 findByConfKey => {
110 ':uPattern' => 'findMenuAppByConfKey'
111 },
112 ':appConfKey' => 'getMenuApp'
113 }
114 },
115 },
116 history => {
117 ':uid' => 'getHistory',
118 },
119 },
120 },
121 ['GET']
122 )
123  
124 ->addRoute(
125 api => {
126 v1 => {
127 providers => {
128 oidc => {
129 rp => 'addOidcRp'
130 },
131 saml => {
132 sp => 'addSamlSp'
133 },
134 cas => {
135 app => 'addCasApp'
136 },
137 },
138 menu => {
139 cat => 'addMenuCat',
140 app => {
141 ':confKey' => 'addMenuApp'
142 }
143 },
144 secondFactor => {
145 ':uid' => {
146 type => {
147 ':type' => 'addSecondFactorByType'
148 },
149 '*' => 'addSecondFactor'
150 },
151 },
152 },
153 },
154 ['POST']
155 )
156  
157 ->addRoute(
158 api => {
159 v1 => {
160 providers => {
161 oidc => {
162 rp => { ':confKey' => 'replaceOidcRp' }
163 },
164 saml => {
165 sp => { ':confKey' => 'replaceSamlSp' }
166 },
167 cas => {
168 app => { ':confKey' => 'replaceCasApp' }
169 },
170 },
171 menu => {
172 cat => { ':confKey' => 'replaceMenuCat' },
173 app => {
174 ':confKey' => {
175 ':appConfKey' => 'replaceMenuApp'
176 }
177 }
178 },
179 },
180 },
181 ['PUT']
182 )
183  
184 ->addRoute(
185 api => {
186 v1 => {
187 providers => {
188 oidc => {
189 rp => { ':confKey' => 'updateOidcRp' }
190 },
191 saml => {
192 sp => { ':confKey' => 'updateSamlSp' }
193 },
194 cas => {
195 app => { ':confKey' => 'updateCasApp' }
196 },
197 },
198 menu => {
199 cat => { ':confKey' => 'updateMenuCat' },
200 app => {
201 ':confKey' => {
202 ':appConfKey' => 'updateMenuApp'
203 }
204 }
205 },
206 },
207 },
208 ['PATCH']
209 )
210  
211 ->addRoute(
212 api => {
213 v1 => {
214 providers => {
215 oidc => {
216 rp => { ':confKey' => 'deleteOidcRp' }
217 },
218 saml => {
219 sp => { ':confKey' => 'deleteSamlSp' }
220 },
221 cas => {
222 app => { ':confKey' => 'deleteCasApp' }
223 },
224 },
225 secondFactor => {
226 ':uid' => {
227 id => {
228 ':id' => 'deleteSecondFactorsById'
229 },
230 type => {
231 ':type' => 'deleteSecondFactorsByType'
232 },
233 '*' => 'deleteSecondFactors'
234 },
235 },
236 menu => {
237 cat => { ':confKey' => 'deleteMenuCat' },
238 app => {
239 ':confKey' => {
240 ':appConfKey' => 'deleteMenuApp'
241 }
242 }
243 },
244 },
245 },
246 ['DELETE']
247 );
248  
249 45 $self->setTypes($conf);
250 45 ▶ $self->{multiValuesSeparator} ||= '; ';
Condition50%1/2
$self->{"multiValuesSeparator"} ||= "; "
l!l
045
MC/DC0%0/1
$self->{"multiValuesSeparator"} ||= "; "
$self->{"multiValuesSeparator"}
Truth table50%1/2
A
A= $self->{"multiValuesSeparator"}
Aresult
11
00
251 45 ▶ $self->{hiddenAttributes} //= "_password";
Condition50%1/2
$self->{"hiddenAttributes"} //= "_password"
l!l
045
MC/DC0%0/1
$self->{"hiddenAttributes"} //= "_password"
$self->{"hiddenAttributes"}
Truth table50%1/2
A
A= $self->{"hiddenAttributes"}
Aresult
11
00
252 45 return 1;
253 }
254  
255 28 1;
« blib/lib/Lemonldap/NG/Manager/2ndFA.pm ↑ Summary blib/lib/Lemonldap/NG/Manager/Cli/Lib.pm »