Skip to content

Commit

Permalink
Merge pull request #9 from guimard/secu
Browse files Browse the repository at this point in the history
OIDC patch
  • Loading branch information
guimard authored Aug 29, 2024
2 parents 3b19b7b + f578e39 commit e7e8a84
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changes

* 2024-08-29:
* Add security patch
* Add `_ldapsearch` command
* 2024-08-22:
* Add Mauritian Creole translation
* Add `LANGUAGES` variable
Expand Down
2 changes: 1 addition & 1 deletion portal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ COPY *.patch /
RUN for p in appgrid.patch jwt-type.patch app-scope.patch ignorepollers.patch \
fixedLogout.patch more-logs.patch introspec-for-public-clients.patch \
token-exchange.patch redirect-ajax.patch back-channel-debug.patch \
crowdsec.patch recaptcha.patch msg-broker.patch mfe.patch \
crowdsec.patch recaptcha.patch msg-broker.patch mfe.patch security.patch \
; do echo patch $p && patch -p1 < $p; done && \
rm -f /*.patch && \
echo "# Install nginx configuration files" && \
Expand Down
98 changes: 98 additions & 0 deletions portal/install/usr/bin/_ldapsearch
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/perl

use strict;
use warnings;
use Net::LDAP;
use Getopt::Long;
use Pod::Usage;

# Variables pour les options de ligne de commande
my $host = 'localhost';
my $port = 389;
my $binddn;
my $password;
my $base;
my $scope = 'sub'; # sub, one, or base
my $filter = '(objectClass=*)';
my @attrs;
my $url;
my $help = 0;
my $x;

# Récupération des options
GetOptions(
'x' => \$x,
'h|host=s' => \$host,
'H|url=s' => \$url,
'p|port=i' => \$port,
'D|binddn=s' => \$binddn,
'w|password=s' => \$password,
'b|base=s' => \$base,
's|scope=s' => \$scope,
'f|filter=s' => \$filter,
'a|attrs=s' => \@attrs,
'help|?' => \$help,
) or pod2usage(2);

pod2usage(1) if $help;

$filter = shift if @ARGV;

@attrs = @ARGV if ( @ARGV and !@attrs );

# Connexion au serveur LDAP
my $ldap = Net::LDAP->new( $url ? ($url) : ( $host, port => $port ) )
or die "Erreur de connexion à " . ( $url ? $url : "$host:$port" ) . " : $@";

# Authentification
if ( $binddn && $password ) {
my $mesg = $ldap->bind( $binddn, password => $password );
die "Erreur d'authentification: ", $mesg->error if $mesg->code;
}

# Recherche LDAP
my $mesg = $ldap->search(
base => $base,
scope => $scope,
filter => $filter,
( @attrs ? ( attrs => \@attrs ) : () ),
);

# Vérification des erreurs de recherche
die "Erreur lors de la recherche: ", $mesg->error if $mesg->code;

# Affichage des résultats
foreach my $entry ( $mesg->entries ) {
$entry->dump; # Affiche toutes les informations de l'entrée
}

# Fermeture de la connexion LDAP
$ldap->unbind;

__END__
=head1 NAME
ldapsearch.pl - Un utilitaire Perl qui imite ldapsearch
=head1 SYNOPSIS
ldapsearch.pl [options]
Options:
-h | --host Nom d'hôte du serveur LDAP (par défaut: localhost)
-p | --port Port du serveur LDAP (par défaut: 389)
-D | --binddn DN pour se lier au serveur LDAP
-w | --password Mot de passe pour l'authentification
-b | --base DN de base pour la recherche
-s | --scope Portée de la recherche: base, one, sub (par défaut: sub)
-f | --filter Filtre LDAP pour la recherche (par défaut: (objectClass=*))
-a | --attrs Attributs à récupérer (peut être utilisé plusieurs fois)
--help Affiche ce message d'aide
=head1 DESCRIPTION
Ce script Perl imite le comportement de base de la commande ldapsearch.
=cut
15 changes: 15 additions & 0 deletions portal/security.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- a/usr/share/perl5/Lemonldap/NG/Portal/Lib/OpenIDConnect.pm
+++ b/usr/share/perl5/Lemonldap/NG/Portal/Lib/OpenIDConnect.pm
@@ -1767,6 +1767,12 @@ sub checkEndPointAuthenticationCredentials {
"Relying Party $rp is public, do not check client secret");
}
else {
+ if ( $method eq "none" ) {
+ $self->logger->error(
+ "Relying Party $rp is confidential but no known method was used"
+ . " to authenticate on token endpoint" );
+ return undef;
+ }
if ( $method =~ /^client_secret_(?:basic|post)$/ ) {
unless ($client_secret) {
$self->logger->error(
2 changes: 1 addition & 1 deletion uwsgi-portal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ COPY *.patch /
RUN for p in appgrid.patch jwt-type.patch app-scope.patch ignorepollers.patch \
fixedLogout.patch more-logs.patch introspec-for-public-clients.patch \
token-exchange.patch redirect-ajax.patch back-channel-debug.patch \
crowdsec.patch recaptcha.patch msg-broker.patch mfe.patch \
crowdsec.patch recaptcha.patch msg-broker.patch mfe.patch security.patch \
; do echo patch $p && patch -p1 < $p; done && \
rm -f /*.patch && \
echo "# Install nginx configuration files" && \
Expand Down
98 changes: 98 additions & 0 deletions uwsgi-portal/install/usr/bin/_ldapsearch
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/perl

use strict;
use warnings;
use Net::LDAP;
use Getopt::Long;
use Pod::Usage;

# Variables pour les options de ligne de commande
my $host = 'localhost';
my $port = 389;
my $binddn;
my $password;
my $base;
my $scope = 'sub'; # sub, one, or base
my $filter = '(objectClass=*)';
my @attrs;
my $url;
my $help = 0;
my $x;

# Récupération des options
GetOptions(
'x' => \$x,
'h|host=s' => \$host,
'H|url=s' => \$url,
'p|port=i' => \$port,
'D|binddn=s' => \$binddn,
'w|password=s' => \$password,
'b|base=s' => \$base,
's|scope=s' => \$scope,
'f|filter=s' => \$filter,
'a|attrs=s' => \@attrs,
'help|?' => \$help,
) or pod2usage(2);

pod2usage(1) if $help;

$filter = shift if @ARGV;

@attrs = @ARGV if ( @ARGV and !@attrs );

# Connexion au serveur LDAP
my $ldap = Net::LDAP->new( $url ? ($url) : ( $host, port => $port ) )
or die "Erreur de connexion à " . ( $url ? $url : "$host:$port" ) . " : $@";

# Authentification
if ( $binddn && $password ) {
my $mesg = $ldap->bind( $binddn, password => $password );
die "Erreur d'authentification: ", $mesg->error if $mesg->code;
}

# Recherche LDAP
my $mesg = $ldap->search(
base => $base,
scope => $scope,
filter => $filter,
( @attrs ? ( attrs => \@attrs ) : () ),
);

# Vérification des erreurs de recherche
die "Erreur lors de la recherche: ", $mesg->error if $mesg->code;

# Affichage des résultats
foreach my $entry ( $mesg->entries ) {
$entry->dump; # Affiche toutes les informations de l'entrée
}

# Fermeture de la connexion LDAP
$ldap->unbind;

__END__
=head1 NAME
ldapsearch.pl - Un utilitaire Perl qui imite ldapsearch
=head1 SYNOPSIS
ldapsearch.pl [options]
Options:
-h | --host Nom d'hôte du serveur LDAP (par défaut: localhost)
-p | --port Port du serveur LDAP (par défaut: 389)
-D | --binddn DN pour se lier au serveur LDAP
-w | --password Mot de passe pour l'authentification
-b | --base DN de base pour la recherche
-s | --scope Portée de la recherche: base, one, sub (par défaut: sub)
-f | --filter Filtre LDAP pour la recherche (par défaut: (objectClass=*))
-a | --attrs Attributs à récupérer (peut être utilisé plusieurs fois)
--help Affiche ce message d'aide
=head1 DESCRIPTION
Ce script Perl imite le comportement de base de la commande ldapsearch.
=cut
15 changes: 15 additions & 0 deletions uwsgi-portal/security.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- a/usr/share/perl5/Lemonldap/NG/Portal/Lib/OpenIDConnect.pm
+++ b/usr/share/perl5/Lemonldap/NG/Portal/Lib/OpenIDConnect.pm
@@ -1767,6 +1767,12 @@ sub checkEndPointAuthenticationCredentials {
"Relying Party $rp is public, do not check client secret");
}
else {
+ if ( $method eq "none" ) {
+ $self->logger->error(
+ "Relying Party $rp is confidential but no known method was used"
+ . " to authenticate on token endpoint" );
+ return undef;
+ }
if ( $method =~ /^client_secret_(?:basic|post)$/ ) {
unless ($client_secret) {
$self->logger->error(

0 comments on commit e7e8a84

Please sign in to comment.