-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
4 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ PIA-BACK is developped with RubyOnRails providing a RESTful API for the PIA and | |
[![Rails Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rails.rubystyle.guide) | ||
|
||
## Wiki for a production environment | ||
You can follow ![the wiki](https://github.com/LINCnil/pia-back/wiki) for a full production installation of `pia` (frontend) and `pia-back` (backend) applications on an Ubuntu server. | ||
**You can follow ![the wiki](https://github.com/LINCnil/pia-back/wiki) for a full production installation of the `pia` (frontend) and `pia-back` (backend) applications on an Ubuntu server.** | ||
|
||
## Requirements | ||
- [pia (front-end) application](https://github.com/LINCnil/pia) | ||
|
@@ -26,127 +26,12 @@ You can follow ![the wiki](https://github.com/LINCnil/pia-back/wiki) for a full | |
- Disk Space : 20Go | ||
- OS : preferably Linux but other OS works as well | ||
|
||
# Ruby installation | ||
See the [Install Ruby](https://github.com/LINCnil/pia-back/wiki/Install-ruby) page in the Wiki. | ||
|
||
## PostgreSQL installation | ||
See the [Install PostgreSQL](https://github.com/LINCnil/pia-back/wiki/Install-PostgreSQL) page in the Wiki. | ||
|
||
## Clone the repository | ||
`git clone https://github.com/LINCnil/pia-back.git` | ||
|
||
## Go to the folder pia-back | ||
`cd pia-back` | ||
|
||
## Create and fill the file database.yml | ||
`cp config/database.example.yml config/database.yml` | ||
|
||
Fill the fields `username` and `password` for each environment with the PostgreSQL username and password created in the step "PostgreSQL installation". | ||
|
||
## Install all dependencies | ||
`bundle install` | ||
|
||
## Generate and fill the secret_key_base in your credentials | ||
Generate the `secret_key_base` with `bin/rake secret` and add it in your credentials using `EDITOR='nano' rails credentials:edit` : | ||
|
||
``` | ||
secret_key_base: [Fill it with the secret key base you have generated] | ||
``` | ||
|
||
## Create and fill the file `.env` file | ||
Go in the root path of the back project then `cp .env-example .env`. | ||
|
||
Generate the `DEVISE_SECRET_KEY` with `bin/rake secret` and paste the secret key in the file. | ||
|
||
Generate the `DEVISE_PEPPER` with `bin/rake secret` and paste the secret key in the file. | ||
|
||
## Create the database | ||
`bin/rake db:create` | ||
|
||
## Create tables | ||
`bin/rake db:migrate` | ||
|
||
## Configure the application | ||
|
||
Set `ENABLE_AUTHENTICATION=true` inside your `.env` file | ||
|
||
Enter the rails console with `bin/rails c` | ||
|
||
Launch the command `Doorkeeper::Application.create(name: "PIA", redirect_uri: "urn:ietf:wg:oauth:2.0:oob", scopes: ["read", "write"])` | ||
|
||
Find your Client ID and Client SECRET by using `Doorkeeper::Application.select(:uid, :secret).last.uid` and `Doorkeeper::Application.select(:uid, :secret).last.secret` | ||
|
||
See: | ||
|
||
![image](https://github.com/LINCnil/pia-back/assets/24872475/b82f817d-6faa-4e9a-b5bb-df056049abc5) | ||
|
||
You will need the CLIENT ID and the CLIENT SECRET data to enable the authentication mode in your PIA application, in the settings page. | ||
|
||
## Enable the authentication mode | ||
|
||
### Create the first admin account | ||
|
||
Enter the rails console with `bin/rails c` | ||
|
||
Launch the command `User.create(email: 'YOUR_EMAIL', password: 'Azeazeaze123-', password_confirmation: 'Azeazeaze123-')` (your password should be at least 12 characters long, with numbers and special characters). | ||
|
||
Get your user, add him all roles and unlock him with the **unlock_access!** method: | ||
|
||
``` | ||
a = User.last | ||
a.is_technical_admin = true | ||
a.is_functional_admin = true | ||
a.is_user = true | ||
a.unlock_access! | ||
a.save | ||
``` | ||
|
||
### Enable LDAP mode (optional) | ||
If you want to use the LDAP authentification mode, set `DEVISE_LDAP_LOGGER=true` inside your `.env` file. | ||
|
||
|
||
Set up the environment credentials variables using `EDITOR='nano' rails credentials:edit`: | ||
|
||
``` | ||
ldap_host: [Fill it with the LDAP host] | ||
ldap_port: [Fill it with the LDAP port] | ||
ldap_attribute: [Fill it with the LDAP attribute] | ||
ldap_base: [Fill it with the LDAP base] | ||
ldap_ssl: [true or false] | ||
``` | ||
|
||
If admin user binding is a necessity, | ||
set `DEVISE_LDAP_LOGGER_ADMIN_BIND=true` inside your `.env` file and set up LDAP admin user credentials: | ||
|
||
``` | ||
ldap_admin_user: [Fill it with the LDAP admin user] | ||
ldap_admin_user_password: [Fill it with admin user password] | ||
``` | ||
|
||
## SMTP configuration | ||
Set up the environment credentials variables using `EDITOR='nano' rails credentials:edit` : | ||
|
||
``` | ||
email_from: [email protected] | ||
smtp_address: xxxx | ||
smtp_port: xxxx | ||
smtp_domain: xxxx | ||
smtp_user_name: xxxx | ||
smtp_password: xxxx | ||
smtp_authentication: :cram_md5 | ||
smtp_enable_starttls_auto: true | ||
``` | ||
|
||
|
||
## Configure the default locale for the authentication emails | ||
|
||
The PIA tool can send different emails when the authentication module is enabled (new user, new evaluation ready, ...). | ||
|
||
The default locale for the content of the authentication emails is English (en). | ||
|
||
Define `DEFAULT_LOCALE="[locale key]"` inside your `.env` file to change the locale. | ||
|
||
For example, if you want to have French translations for the authenication emails, configure `DEFAULT_LOCALE="fr"` in your `.env` file. | ||
|
||
Supported locales: bg, cs, da, de, el, en, es, et, fi, fr, hr, hu, it, lt, lv, nl, no, pl, pt, ro, sl, sv. | ||
|
||
## Run the application in a development environment | ||
- `bin/rails s` your server will be accessible with the URL `localhost:3000` | ||
|
||
|
@@ -171,12 +56,3 @@ Update the repository : `git pull` | |
Update the dependencies : `bundle install` | ||
|
||
Update the database : `bin/rake db:migrate` | ||
|
||
## Change the default locale | ||
Pia back mailer work with rails-i18n. For update default locale, | ||
go to change this line in rails configuration: | ||
|
||
In config/application.rb | ||
``` | ||
config.i18n.default_locale = :en | ||
``` |