aboutsummaryrefslogtreecommitdiff
path: root/auth-flow.conf.php
blob: e9f6e612bf997c13b62005449442cae4d7482a96 (plain)
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
/*
  in this file is where you can customise the authentication flow.
  it's evaluated when a user goes to the login page.
  you can access these variables:
  - $context contains a Psso\Context object, describing what the user has
    already done up to this point, and what's known about them
  - $last contains the most recent ChallengeResult, or null if no challenges
    were completed yet
  you are expected to return either an array of Challenge subclasses, which
  specifies what options the user has to continue (if you return multiple, they
  will be presented in parallel for the user to choose just one to answer), or
  an empty array, which indicates the auth flow has failed and cannot continue,
  or the boolean 'true', which indicates the auth flow has succeeded and we can
  trust that the user is who they say they are.
*/

use Psso\Challenge\{Username, Password, Totp};

if ($last?->successful) {
    // unfortunately only Dummy provider supports Totp so far, therefore don't
    //return match ($last->type) {
    //    Password::class => [Totp::class],
    //    Totp::class => true,
    //};
    return true;
}

return [$last?->type ?? Password::class];