Le logiciel PIA est un outil distribué librement par la CNIL afin de faciliter la réalisation d’analyses d’impact sur la protection des données prévues par le RGPD.
PIA-BACK est développé avec le framework RubyOnRails mettant à disposition une API RESTful à destination des outils PIA et PIA-APP.
The PIA software is a free tool published by the CNIL which aims to help data controllers build and demonstrate compliance to the GDPR. PIA-BACK is developped with RubyOnRails providing a RESTful API for the PIA and PIA-APP applications.
You can follow the wiki for a full production installation of the pia (frontend) and pia-back (backend) applications on an Ubuntu server.
- pia (front-end) application
- Ruby 3.4.x
- Rails 8.0.x
- PostgreSQL 13+
- CPU : i5
- Ram: 4Go
- Disk Space : 20Go
- OS : preferably Linux but other OS works as well
See the Install Ruby page in the Wiki.
See the Install PostgreSQL page in the Wiki.
-
bin/rails syour server will be accessible with the URLlocalhost:3000 -
You can specify the option
-bto bind to a public IP address or domain name and-pto use a different port.For example:
bin/rails s -b 123.456.789.101 -p 8080your server will be accessible with the URL123.456.789.101:8080 -
Then, in the pia (front-end) application, use this URL to enable the server mode.
-
Fill the field in "Tools" > "Settings"
-
Every user will have to fill the server URL, the client ID and the client SECRET fields to access the authentication interface.
Configure the LDAP server for each environment in config/ldap.yml. Development
reads ldap_host, ldap_port, ldap_attribute, ldap_base, ldap_admin_user,
ldap_admin_user_password and ldap_ssl from Rails credentials.
- Set
LDAP_ENABLEDtotrueto enable LDAP authentication and tofalseto disable it (1/0,yes/noandon/offare also accepted, ignoring case). Any other value is rejected: the error is logged on each login and local authentication is used instead. - Set
LDAP_ADMIN_BINDtotrueto use the configured admin credentials for directory searches, orfalse(the default) for anonymous searches. It accepts the same values asLDAP_ENABLED. - Deprecated:
DEVISE_LDAP_LOGGERandDEVISE_LDAP_LOGGER_ADMIN_BINDare read only whileLDAP_ENABLEDandLDAP_ADMIN_BINDrespectively are unset or empty, and keep their historical meaning: any non-emptyDEVISE_LDAP_LOGGERenables LDAP, even the stringfalse, and any definedDEVISE_LDAP_LOGGER_ADMIN_BIND, even an empty one, enables the admin bind. A warning at boot states the value each of them currently stands for, so renaming one without checking can reverse the behavior.DEVISE_LDAP_LOGGERno longer controls debug logging. - Set
ssltosimple_tls(ortrue) for LDAPS, orstart_tlsfor StartTLS. The server certificate and hostname are verified using the system trust store. An unset or falsesslretains legacy plaintext LDAP behavior and logs a warning: credentials will be transmitted without encryption.
For a private CA, configure encryption, which takes precedence over ssl:
encryption:
method: start_tls
tls_options:
ca_file: /path/to/ldap-ca.pemThe previous LDAP integration did not validate the certificate chain, so a
self-signed or private-CA certificate that used to work now fails with
LDAP TLS certificate verification failed in the logs. Trusting the CA as above
is the recommended fix. As a last resort, verification can be disabled
explicitly:
encryption:
method: start_tls
verify_certificates: falseverify_certificates must be a boolean and is only read from encryption;
tls_options cannot disable verification. Setting it to false turns off both
certificate and hostname verification, so anyone able to intercept the
connection can impersonate the directory and capture passwords. A warning is
logged on every connection.
The login is searched using the configured attribute. If the search returns no
user, or anonymous binding or searching is refused, authentication also tries
the legacy DN format attribute=login,base and logs an info message that does
not identify the user. A successful first LDAP login creates a local user with
the LDAP mail attribute, or the login when no email is available.
Directories usually ignore case and extra spaces when searching, so ALICE and
alice both find the user stored as alice. The local account is matched on
the login as spelled by the directory, not on what was typed, so every spelling
signs in to the same account. When the directory does not return the login
attribute (for example when the legacy DN format is used), the typed login is
used. Accounts created by the previous integration with another spelling are
still found by the typed login when no account matches the directory spelling.
Local logins are never matched case-insensitively, because some directories
distinguish Alice from alice.
A first LDAP login never links itself to an existing local account by email: the
directory mail attribute is not proof that the person owns that account. When
the LDAP email (or the login, if the directory returns no mail) already
belongs to a local account with another login, no account is created and the
token request fails with a 422 error; the logs show Validation failed: Email has already been taken. To let that user sign in with LDAP, set the login of
the existing local account to the LDAP login, for example from a Rails console:
User.find_by!(email: 'alice@example.test').update!(login: 'alice')Alternatively, give one of the two accounts another email. The users API does
not accept a login. Two simultaneous first logins of the same user can make one
of the requests fail, because the other one creates the account; signing in
again succeeds.
If the LDAP server refuses the user bind, whatever the result code
(wrong password, locked or disabled account, ...), the result code is logged and
existing local email/password authentication remains available. The same applies
when the LDAP check itself fails (connection or TLS error, invalid configuration,
ambiguous search result): the error is logged at error level and the login falls
back to local authentication, so local administrator accounts keep working during
an LDAP outage. Users created by a first LDAP login have a random local password,
so they cannot sign in with their LDAP password until the directory is available
again. A hanging directory delays each login by up to 10 seconds before the
fallback.
The previous LDAP group and attribute authorization checks were disabled in this application and are not implemented. An LDAP configuration that explicitly enables group checks is rejected rather than silently bypassing them. LDAP password changes are not performed by this application.
Go to the folder pia-back : cd pia-back
Update the repository : git pull
Update the dependencies : bundle install
Update the database : bin/rake db:migrate
This migration utility converts file attachments from the legacy Carrierwave storage system to Rails' ActiveStorage. Note that this migration only works for locally stored files and requires the correct file structure within the data/attachment/attached_file/ directory.
RAILS_ENV=production bin/rake active_storage_migration
