U2F registration works (#1148)

environments/ppa-mbqj77/deployments/1
Xavier Guimard 8 years ago
parent e8fec72141
commit 41da50b8ca
  1. 1
      lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm
  2. 7
      lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI.pm
  3. 6
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm
  4. 8
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Attributes.pm
  5. 2
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Tree.pm
  6. 2
      lemonldap-ng-manager/site/static/languages/en.json
  7. 2
      lemonldap-ng-manager/site/static/languages/fr.json
  8. 2
      lemonldap-ng-manager/site/static/reverseTree.json
  9. 2
      lemonldap-ng-manager/site/static/struct.json
  10. 5
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Plugins.pm
  11. 37
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Register/U2F.pm
  12. 4
      lemonldap-ng-portal/site/coffee/u2fregistration.coffee
  13. 11
      lemonldap-ng-portal/site/htdocs/static/common/js/u2fregistration.js
  14. 2
      lemonldap-ng-portal/site/htdocs/static/common/js/u2fregistration.min.js

@ -243,7 +243,6 @@ sub defaultValues {
'timeoutActivityInterval' => 60, 'timeoutActivityInterval' => 60,
'trustedProxies' => '', 'trustedProxies' => '',
'twitterAuthnLevel' => 1, 'twitterAuthnLevel' => 1,
'u2fAppId' => 'Lemonldap::NG',
'userControl' => '^[\\w\\.\\-@]+$', 'userControl' => '^[\\w\\.\\-@]+$',
'userDB' => 'Demo', 'userDB' => 'Demo',
'useRedirectOnError' => 1, 'useRedirectOnError' => 1,

@ -123,12 +123,7 @@ sub sendError {
); );
# SOAP responses # SOAP responses
if ( if ( $req->env->{HTTP_SOAPACTION} ) {
$req->accept =~ m#(?:application|text)/xml#
or ( $req->content_type
and $req->content_type =~ m#(?:application|text)/xml# )
)
{
my $s = '<soapenv:Body> my $s = '<soapenv:Body>
<soapenv:Fault> <soapenv:Fault>
<Faultcode>soapenv:Client</Faultcode> <Faultcode>soapenv:Client</Faultcode>

@ -2830,9 +2830,9 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
'default' => 0, 'default' => 0,
'type' => 'bool' 'type' => 'bool'
}, },
'u2fAppId' => { 'u2fSelfRegistration' => {
'default' => 'Lemonldap::NG', 'default' => 0,
'type' => 'text' 'type' => 'bool'
}, },
'userControl' => { 'userControl' => {
'default' => '^[\\w\\.\\-@]+$', 'default' => '^[\\w\\.\\-@]+$',

@ -954,10 +954,10 @@ sub attributes {
default => 0, default => 0,
documentation => 'U2F activation', documentation => 'U2F activation',
}, },
u2fAppId => { u2fSelfRegistration => {
default => 'Lemonldap::NG', type => 'bool',
type => 'text', default => 0,
documentation => 'U2F application ID', documentation => 'U2F self registration activation',
}, },
# Single session # Single session

@ -582,7 +582,7 @@ sub tree {
{ {
title => 'u2f', title => 'u2f',
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => [ 'u2fActivation', 'u2fAppId', ] nodes => [ 'u2fActivation', 'u2fSelfRegistration', ]
}, },
{ {
title => 'security', title => 'security',

@ -631,7 +631,7 @@
"twitterSecret": "API secret", "twitterSecret": "API secret",
"u2f": "U2F", "u2f": "U2F",
"u2fActivation": "Activation", "u2fActivation": "Activation",
"u2fAppId": "Application ID", "u2fSelfRegistration": "Self registration",
"uid": "Identifier", "uid": "Identifier",
"unknownAttrOrMacro": "Unknown attribute or macro", "unknownAttrOrMacro": "Unknown attribute or macro",
"unknownError": "Unknown error", "unknownError": "Unknown error",

@ -631,7 +631,7 @@
"twitterSecret": "Secret de l'API", "twitterSecret": "Secret de l'API",
"u2f": "U2F", "u2f": "U2F",
"u2fActivation": "Activation", "u2fActivation": "Activation",
"u2fAppId": "Identifiant de l'application", "u2fSelfRegistration": "Activation de l'enregistrement",
"uid": "Identifiant", "uid": "Identifiant",
"unknownAttrOrMacro": "Attribut ou macro inconnu", "unknownAttrOrMacro": "Attribut ou macro inconnu",
"unknownError": "Erreur inconnue", "unknownError": "Erreur inconnue",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -76,7 +76,10 @@ sub enabledPlugins {
# U2F # U2F
if ( $self->conf->{u2fActivation} ) { if ( $self->conf->{u2fActivation} ) {
push @res, '::Register::U2F', '::Plugins::U2F'; push @res, '::Plugins::U2F';
}
if ( $self->conf->{u2fSelfRegistration} ) {
push @res, '::Register::U2F';
} }
# Check if custom plugins are required # Check if custom plugins are required

@ -9,6 +9,15 @@ extends 'Lemonldap::NG::Portal::Main::Plugin';
has crypter => ( is => 'rw' ); has crypter => ( is => 'rw' );
has origin => (
is => 'rw',
default => sub {
my $p = $_[0]->{conf}->{portal};
$p =~ s#^(https?://[^/]+).*$#$1#;
return $p;
}
);
sub init { sub init {
my ($self) = @_; my ($self) = @_;
eval 'use Crypt::U2F::Server::Simple'; eval 'use Crypt::U2F::Server::Simple';
@ -19,8 +28,8 @@ sub init {
unless ( unless (
$self->crypter( $self->crypter(
Crypt::U2F::Server::Simple->new( Crypt::U2F::Server::Simple->new(
appId => $self->conf->{u2fAppId}, appId => $self->origin,
origin => $self->conf->{portal}, origin => $self->origin,
) )
) )
) )
@ -36,30 +45,24 @@ sub run {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
# Check for registration response # Check for registration response
if ( my $rd = $req->param('registration') ) { if ( my $response = $req->param('registration') ) {
$self->lmLog( "Get registration data $rd", 'debug' ); $self->lmLog( "Get registration data $response", 'debug' );
my ( $keyHandle, $userKey ) = $self->crypter->registrationVerify($rd); my ( $keyHandle, $userKey ) =
$self->crypter->registrationVerify($response);
if ( $keyHandle and $userKey ) { if ( $keyHandle and $userKey ) {
$self->lmLog( "Handle: $keyHandle, Key: $userKey", 'debug' );
$self->p->updatePersistentSession( $req, $self->p->updatePersistentSession( $req,
{ _u2fHandle => $keyHandle, _u2fKey => $userKey } ); { _u2fHandle => $keyHandle, _u2fKey => $userKey } );
return $self->p->sendHtml( $req, 'u2fregister', return $self->p->sendHtml( $req, 'u2fregister',
params => { SUCCESS => 1 } ); params => { SUCCESS => 1 } );
} }
else { $self->p->userError( 'U2F Registration failed: '
$self->lmLog( . Crypt::U2F::Server::Simple::lastError() );
'U2F Registration failed: ' return $self->p->sendHtml( $req, 'u2fregister',
. Crypt::U2F::Server::Simple::lastError(), params => { FAILED => 1 } );
'notice'
);
return $self->p->sendHtml( $req, 'u2fregister',
params => { FAILED => 1 } );
}
} }
my $challenge = $self->crypter->registrationChallenge; my $challenge = $self->crypter->registrationChallenge;
return $self->p->sendHtml( $req, 'u2fregister', return $self->p->sendHtml( $req, 'u2fregister',
params => params => { CHALLENGE => $challenge, APPID => $self->origin } );
{ CHALLENGE => $challenge, APPID => $self->conf->{u2fAppId} } );
} }
1; 1;

@ -3,9 +3,11 @@ LemonLDAP::NG U2F registration script
### ###
register = -> register = ->
request = request = [
challenge: window.datas.challenge challenge: window.datas.challenge
version: 'U2F_V2' version: 'U2F_V2'
]
console.log 'Register: ', request
u2f.register window.datas.appId, request, [], (data) -> u2f.register window.datas.appId, request, [], (data) ->
$('#bind-data').val JSON.stringify data $('#bind-data').val JSON.stringify data
$('#bind-form').submit() $('#bind-form').submit()

@ -9,10 +9,13 @@ LemonLDAP::NG U2F registration script
register = function() { register = function() {
var request; var request;
request = { request = [
challenge: window.datas.challenge, {
version: 'U2F_V2' challenge: window.datas.challenge,
}; version: 'U2F_V2'
}
];
console.log('Register: ', request);
return u2f.register(window.datas.appId, request, [], function(data) { return u2f.register(window.datas.appId, request, [], function(data) {
$('#bind-data').val(JSON.stringify(data)); $('#bind-data').val(JSON.stringify(data));
return $('#bind-form').submit(); return $('#bind-form').submit();

@ -1 +1 @@
(function(){var a;a=function(){var b;b={challenge:window.datas.challenge,version:"U2F_V2"};return u2f.register(window.datas.appId,b,[],function(c){$("#bind-data").val(JSON.stringify(c));return $("#bind-form").submit()})};$(document).ready(function(){return setTimeout(a,1000)})}).call(this); (function(){var a;a=function(){var b;b=[{challenge:window.datas.challenge,version:"U2F_V2"}];console.log("Register: ",b);return u2f.register(window.datas.appId,b,[],function(c){$("#bind-data").val(JSON.stringify(c));return $("#bind-form").submit()})};$(document).ready(function(){return setTimeout(a,1000)})}).call(this);
Loading…
Cancel
Save