-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
595 lines (593 loc) · 17.5 KB
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
<?php
namespace JobRouter\Plugin { if(false) {
class ExtensionRegistry
{
}
class ExtensionTypeOperator
{
public function __construct(\JobRouter\Plugin\ExtensionRegistry $registry)
{
}
public function registerAuthenticationFactor(string $factorType, string $className)
{
}
public function registerTranslations(string $path)
{
}
}
}}
namespace JobRouter\Log { if(false) {
/**
* Describes a logger instance.
*
* The message MUST be a string or object implementing __toString().
*
* The message MAY contain placeholders in the form: {foo} where foo
* will be replaced by the context data in key "foo".
*
* The context array can contain arbitrary data. The only assumption that
* can be made by implementors is that if an Exception instance is given
* to produce a stack trace, it MUST be in a key named "exception".
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
* for the full interface specification.
*/
interface LoggerInterface
{
/**
* System is unusable.
*
* @param string $message
* @param mixed[] $context
*
* @return void
*/
public function emergency($message, array $context = []);
/**
* Action must be taken immediately.
*
* Example: Entire website down, database unavailable, etc. This should
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param mixed[] $context
*
* @return void
*/
public function alert($message, array $context = []);
/**
* Critical conditions.
*
* Example: Application component unavailable, unexpected exception.
*
* @param string $message
* @param mixed[] $context
*
* @return void
*/
public function critical($message, array $context = []);
/**
* Runtime errors that do not require immediate action but should typically
* be logged and monitored.
*
* @param string $message
* @param mixed[] $context
*
* @return void
*/
public function error($message, array $context = []);
/**
* Exceptional occurrences that are not errors.
*
* Example: Use of deprecated APIs, poor use of an API, undesirable things
* that are not necessarily wrong.
*
* @param string $message
* @param mixed[] $context
*
* @return void
*/
public function warning($message, array $context = []);
/**
* Normal but significant events.
*
* @param string $message
* @param mixed[] $context
*
* @return void
*/
public function notice($message, array $context = []);
/**
* Interesting events.
*
* Example: User logs in, SQL logs.
*
* @param string $message
* @param mixed[] $context
*
* @return void
*/
public function info($message, array $context = []);
/**
* Detailed debug information.
*
* @param string $message
* @param mixed[] $context
*
* @return void
*/
public function debug($message, array $context = []);
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param mixed[] $context
*
* @return void
*/
public function log($level, $message, array $context = []);
}
}}
namespace JobRouter\Plugin { if(false) {
interface PluginInterface
{
public function load(\JobRouter\Plugin\ExtensionRegistry $registry) : void;
}
}}
namespace JobRouter\Authentication\Factor\Wizard { if(false) {
/**
* A message displayed to the user on top of the login screen.
*/
abstract class Message
{
public function __construct(string $text)
{
}
public abstract function getType() : string;
public final function getText() : string
{
}
}
/**
* Information about errors during the authentication process.
* Usually these require some action by the user or administrator.
*/
final class ErrorMessage extends \JobRouter\Authentication\Factor\Wizard\Message
{
/**
* @return string
*/
public function getType() : string
{
}
}
/**
* A form field displayed on the login page.
* Requires some input by the user, e.g. a 2FA PIN.
*/
abstract class Field
{
public function __construct(string $name, string $label = '')
{
}
public abstract function getType() : string;
public final function getName() : string
{
}
public final function getLabel() : string
{
}
}
/**
* General information during the authentication process.
*/
final class InfoMessage extends \JobRouter\Authentication\Factor\Wizard\Message
{
public function getType() : string
{
}
}
/**
* A link displayed at the bottom of the login page.
*/
final class Link
{
public function __construct(string $target, string $label)
{
}
public function getTarget() : string
{
}
public function getLabel() : string
{
}
}
/**
* A form field for numerical input.
*/
final class NumberField extends \JobRouter\Authentication\Factor\Wizard\Field
{
public function getType() : string
{
}
}
/**
* A form field for text input.
*/
final class TextField extends \JobRouter\Authentication\Factor\Wizard\Field
{
public function getType() : string
{
}
}
}}
namespace JobRouter\Authentication { if(false) {
interface AuthenticationFactorInterface
{
/**
* Execute authentication factor.
*
* The runtime provides access to the current session data related to the authentication process.
* It also includes a method to determine the current factor (stage).
*
* @param Runtime $runtime
*
* @throws AuthenticationFactorFailedException
*/
public function execute(\JobRouter\Authentication\Runtime $runtime) : void;
/**
* Check authentication factor for validity
*
* If factor is invalid, throw AuthenticationFactorFailedException with a corresponding message. The message will be shown on the login page.
*
* @param Runtime $runtime
*
* @throws AuthenticationFactorFailedException
*/
public function check(\JobRouter\Authentication\Runtime $runtime) : void;
/**
* This method will be called when the checkFactor method throws an AuthenticationFactorFailedException (factor check was unsuccessful)
*
* @param Runtime $runtime
*/
public function handleInvalidFactor(\JobRouter\Authentication\Runtime $runtime) : void;
/**
* @return \JobRouter\Authentication\Factor\Wizard\Field[]
*/
public function getFields() : array;
/**
* @return \JobRouter\Authentication\Factor\Wizard\Message[]
*/
public function getMessages() : array;
/**
* @return \JobRouter\Authentication\Factor\Wizard\Link[]
*/
public function getLinks() : array;
/**
* This method returns the label used in the UserProfile configuration.
*
* @return string
*/
public function getConfigurationLabel() : string;
/**
* This method defines whether the authentication factor is available or not.
*
* @return bool
*/
public function isAvailable() : bool;
}
final class Runtime
{
/**
* Set a variable in the user session in the browser.
*
* @param string $key
* @param string $value
*/
public function setSessionVariable(string $key, string $value) : void
{
}
/**
* Get the value of the session variable with the given key.
*
* @param string $key
*
* @return string|null
*/
public function getSessionVariable(string $key) : ?string
{
}
/**
* Delete the session variable with the given key.
* This should be done at the end of the authentication process.
*
* @param string $key
*/
public function deleteSessionVariable(string $key) : void
{
}
/**
* Returns the user in the current authentication process.
*
* @return \JobRouter\Api\User\ApiUser
*/
public function getUser() : \JobRouter\Api\User\ApiUser
{
}
/**
* Returns the value of the specified request parameter.
* When using Fields in your authentication process, these will
* be specified by the name used to instantiate the Field object.
*
* @param string $name
*
* @return string|null
*/
public function getRequestParameter(string $name) : ?string
{
}
/**
* Returns a logger object that can be used to log events
* for the system administrators.
*
* @return \JobRouter\Log\LoggerInterface
*/
public function getLogger() : \JobRouter\Log\LoggerInterface
{
}
/**
* Returns a formatted date string.
* ID can be specified explicitly, or e.g. the method getDateFormatId of the ApiUser class
* can be used to get the current user's date format.
*
* @param int $id 1 (DD.MM.YYYY), 2 (DD/MM/YYYY), 3 (MM/DD/YYYY), 4 (YYYY-MM-DD)
* @param string|false $date Date string, datetime string, timestamp as string, or false to use the current datetime
* @param false $isTimestamp Specifies if the value in $date is a timestamp
* @param false $fullDateTime Specifies if the time should be considered in addition to the date
* @param string $timezone Timezone name or offset value (e.g. +0200)
*
* @return string
*/
public function getFormattedDate(int $id, $date = false, bool $isTimestamp = false, bool $fullDateTime = false, string $timezone = '') : string
{
}
/**
* Returns a "Back to login" link that resets the current authentication process.
* If no label is provided, a default translation is used.
*
* @param string|null $label
*
* @return \JobRouter\Authentication\Factor\Wizard\Link
*/
public function getResetAuthenticationProcessLink(?string $label = CONST_BACK_TO_LOGIN_PAGE) : \JobRouter\Authentication\Factor\Wizard\Link
{
}
/**
* Returns a link that repeats the current factor within the authentication process.
* This action will trigger the execute method of your Authentication Factor class an additional time,
* and the user will remain in the current step of the authentication process.
*
* @param string $label
*
* @return \JobRouter\Authentication\Factor\Wizard\Link
*/
public function getRepeatFactorLink(string $label) : \JobRouter\Authentication\Factor\Wizard\Link
{
}
}
}}
namespace JobRouter\Api\User { if(false) {
class ApiUser
{
/**
* Returns the current user's username.
*
* @return string
*/
public function getUsername() : string
{
}
/**
* Returns the current user's job functions in an array of strings.
* If an error occurs during the database query to fetch the job functions,
* a JobRouterException containing the DB error message is thrown.
*
* @return array
* @throws \JobRouterException
*/
public function getJobFunctions() : array
{
}
/**
* Checks whether the current user is in the specified job function.
* If an error occurs during the database query to fetch the job functions,
* a JobRouterException containing the DB error message is thrown.
*
* @param string $jobfunction
*
* @return bool
* @throws \JobRouterException
*/
public function isInJobFunction(string $jobfunction) : bool
{
}
/**
* Checks whether the current user has administrator rights.
*
* @return bool
*/
public function hasAdminRights() : bool
{
}
/**
* Checks whether the current user is the owner of any processes.
* If an error occurs during the database query to fetch the processes,
* a JobRouterException containing the DB error message is thrown.
*
* @return bool
* @throws \JobRouterException
*/
public function hasOwnProcesses() : bool
{
}
/**
* Returns the current user's last name.
*
* @return string
*/
public function getLastname() : string
{
}
/**
* Returns the current user's first name.
*
* @return string
*/
public function getPrename() : string
{
}
/**
* Returns the current user's e-mail address.
*
* @return string
*/
public function getEmail() : string
{
}
/**
* Returns the current user's department.
*
* @return string
*/
public function getDepartment() : string
{
}
/**
* Returns the username of the current user's supervisor.
*
* @return string
*/
public function getSupervisor() : string
{
}
/**
* Returns the current user's user defined 1 field.
*
* @return string
*/
public function getUserDefined1() : string
{
}
/**
* Returns the current user's user defined 2 field.
*
* @return string
*/
public function getUserDefined2() : string
{
}
/**
* Returns the current user's user defined 3 field.
*
* @return string
*/
public function getUserDefined3() : string
{
}
/**
* Returns the current user's user defined 4 field.
*
* @return string
*/
public function getUserDefined4() : string
{
}
/**
* Returns the current user's user defined 5 field.
*
* @return string
*/
public function getUserDefined5() : string
{
}
/**
* Returns the URL of the current user's avatar.
*
* @return string
*/
public function getAvatarUrl() : string
{
}
/**
* Returns the decimal separator as configured in the current user's settings.
*
* @return string
*/
public function getDecimalSeparator() : string
{
}
/**
* Returns the thousands separator as configured in the current user's settings.
*
* @return string
*/
public function getThousandsSeparator() : string
{
}
/**
* Returns the current user's language.
*
* @return string
*/
public function getLanguage() : string
{
}
/**
* Returns the current user's full name.
*
* @return string
*/
public function getFullName() : string
{
}
/**
* Returns the current user's date format as specified in their settings.
* If an invalid date format is configured, a default value of YYYY-MM-DD HH:mm:ss is returned.
*
* @return string
*/
public function getDateFormat() : string
{
}
/**
* Returns the corresponding ID of the current user's date format.
* This ID can be used, for example, in the getFormattedDate method of the Runtime class
* to format a date according to the current user's configured date format.
*
* @return int
*/
public function getDateFormatId() : int
{
}
}
}}
namespace { if(false) {
class JobRouterException extends \Exception
{
public function __construct($message, $code = 0, \Throwable $previous = \null)
{
}
}
}}
namespace JobRouter\Authentication { if(false) {
abstract class AuthenticationException extends \JobRouterException
{
}
class AuthenticationFailedException extends \JobRouter\Authentication\AuthenticationException
{
}
class AuthenticationFactorFailedException extends \JobRouter\Authentication\AuthenticationFailedException
{
}
}}