Generate list of currents registrable SFAs from manager code

This commit is contained in:
Maxime Besson 2022-08-30 20:14:42 +02:00
parent 12ca5e62b9
commit 1e8a632606
3 changed files with 26 additions and 12 deletions

View File

@ -28,7 +28,7 @@ sub init {
# Remote Procedure are defined in Lemonldap::NG::Common::Session::REST
# HTML template
$self->addRoute( '2ndfa.html', undef, ['GET'] )
$self->addRoute( '2ndfa.html', 'sfaView', ['GET'] )
->addRoute(
sfa => { ':sessionType' => 'sfa' },
@ -46,6 +46,11 @@ sub init {
$self->{hiddenAttributes} //= "_password";
$self->{hiddenAttributes} .= ' _session_id'
unless $conf->{displaySessionId};
$self->{regSfaTypes} = [
sort map { s/^Yubikey$/UBK/r } split /[\s,]+/,
$conf->{available2FSelfRegistration}
];
return 1;
}
@ -274,4 +279,14 @@ qq{Use of an uninitialized attribute "$group" to group sessions},
);
}
sub sfaView {
my ( $self, $req ) = @_;
return $self->p->sendHtml(
$req, "2ndfa",
params => {
SFATYPES => [ map { { SFATYPE => $_ } } @{ $self->{regSfaTypes} } ],
}
);
}
1;

View File

@ -14,17 +14,11 @@
<ul class="nav navbar-nav" role="grid">
<form class="navbar-form" name="filterForm">
<div class="form-check ">
<input type="checkbox" ng-model="sfatypes.U2F" class="form-check-input" ng-change="search2FA()"/>
<label class="form-check-label" for="U2FCheck">U2F</label>
&nbsp;&nbsp;&&nbsp;&nbsp;
<input type="checkbox" ng-model="sfatypes.TOTP" class="form-check-input" ng-change="search2FA()"/>
<label class="form-check-label" for="TOTPCheck">TOTP</label>
&nbsp;&nbsp;&&nbsp;&nbsp;
<input type="checkbox" ng-model="sfatypes.UBK" class="form-check-input" ng-change="search2FA()"/>
<label class="form-check-label" for="UBKCheck">UBK</label>
&nbsp;&nbsp;&&nbsp;&nbsp;
<input type="checkbox" ng-model="sfatypes.WebAuthn" class="form-check-input" ng-change="search2FA()"/>
<label class="form-check-label" for="WebAuthnCheck">WebAuthn</label>
<TMPL_LOOP NAME=SFATYPES>
<input type="checkbox" ng-model="sfatypes.<TMPL_VAR NAME=SFATYPE>" class="form-check-input" ng-change="search2FA()"/>
<label class="form-check-label" for="<TMPL_VAR NAME=SFATYPE>Check"><TMPL_VAR NAME=SFATYPE></label>
<TMPL_UNLESS NAME="__last__">&nbsp;&nbsp;&amp;&nbsp;&nbsp;</TMPL_UNLESS>
</TMPL_LOOP>
</div>
</form>
</ul>

View File

@ -351,6 +351,11 @@ ok( $res->{count} == 0, 'Found 0 session with 2F device' )
ok( @{ $res->{values} } == 0, 'List 0 result' );
count(3);
ok( $res = &client->_get('/2ndfa.html'), 'Succeed to get /2ndfa.html' );
like( $res->[2]->[0],
qr,<label class="form-check-label" for="TOTPCheck">TOTP</label>, );
count(2);
done_testing( count() );
# Remove sessions directory