You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<palign="center">ReactJS + Flask + Docker<br/>boilerplate using a token-based LDAP authentication</p>
9
+
<palign="center">ReactJS + Flask + Docker (+ K8S)<br/>boilerplate using a token-based LDAP authentication</p>
10
10
11
11
> :smiley: Suggestions and feedbacks are [highly appreciated](https://github.com/flavienbwk/reactjs-flask-ldap-boilerplate/issues/new)
12
12
@@ -20,12 +20,13 @@
20
20
- Flask-Migrate
21
21
- Flask-SQLAlchemy (PostgreSQL was chosen)
22
22
-[Logging and logs rotation](./api/app/utils/Logger.py#L12)
23
-
-[Choose](./app/app/src/App.js#L64) between sidebar and navbar (or use both !)
23
+
-[Choose](./app/app/src/App.js#L65) between sidebar and navbar (or use both !)
24
24
- Responsive design
25
+
- Production and development builds
25
26
26
27
## API documentation
27
28
28
-
I chose to use Swagger to document the API. Just run the API following the steps below and browse to [`http://localhost:5000`](http://localhost:5000)
29
+
I chose to use Swagger to document the API. Run the API following the steps below and go to [`http://localhost:5000`](http://localhost:5000).
29
30
30
31
Here you can take a look at the database architecture scheme :
31
32
@@ -35,76 +36,76 @@ Here you can take a look at the database architecture scheme :
35
36
36
37
> Reminder : there is no `password` field because we use LDAP for authentication.
37
38
38
-
## Setting up the API
39
+
## Getting started (development)
39
40
40
41
The API is made to run with an LDAP server for managing users. Whether use the provided Docker LDAP server or remove the conf. in [`docker-compose.yml`](./docker-compose.yml) and use your own LDAP server.
41
42
42
43
This section will explain to you how to run this project and set-up the LDAP server with one user.
43
44
44
-
### Starting services
45
+
### 1. Starting authentication services
45
46
46
-
First, please change the database/LDAP passwords and keys in `docker-compose.yml`
47
+
1. Copy the `.env.example` to `.env`
47
48
48
-
Then, run :
49
+
```bash
50
+
cp .env.example .env
51
+
```
49
52
50
-
```bash
51
-
docker-compose up ldap phpldapadmin database adminer -d
52
-
```
53
+
> This is a good practice so your `.env` can't be committed along with your modifications (is in `.gitignore`)
54
+
55
+
2. Change the database/LDAP passwords and keys in `.env`
56
+
57
+
You can now run :
53
58
54
-
> **adminer** (PostgreSQL management) will be available through `http://localhost:8082`
55
-
> **phpLDAPAdmin** (LDAP management) will be available through `https://localhost:8081`
59
+
```bash
60
+
docker-compose up ldap phpldapadmin database adminer -d
61
+
```
56
62
57
-
### Creating the first user in the LDAP
63
+
- **adminer** (PostgreSQL management) will be available at `http://localhost:8082`
64
+
- **phpLDAPAdmin** (LDAP management) will be available at `https://localhost:8081`
58
65
59
-
Access phpLDAPAdmin with : `https://localhost:8081`
66
+
### 2. Creating the first user in the LDAP
60
67
61
-
If you are not familiar with LDAP, [read my LDAP user creation guide](./CREATE_LDAP_USER.md) to add your first user
68
+
Access phpLDAPAdmin at `https://localhost:8081` and [follow the LDAP user creation guide](./CREATE_LDAP_USER.md) to add your first user
62
69
63
-
### Run the API
70
+
### 3. NGINX reverse-proxy
64
71
65
-
The database will be automatically set-up thanks to Flask Migrate and any future modification brought to [models](./api/app/model) will be automatically applied to the database when the API is **restarted**.
72
+
This boilerplate includes NGINX as a reverse proxy so we can have a unique endpoint for our app and API. Else, we would have to open two endpoints : one for the app, the other for the API.
66
73
67
74
```bash
68
-
docker-compose up api
75
+
docker-compose up --build -d nginx
69
76
```
70
77
71
-
Access the API and its documentation browsing [`http://localhost:5000`](http://localhost:5000)
78
+
NGINX will auto restart until you have started the app and API below.
72
79
73
-
##Setting up the web application
80
+
### 4. Run the API
74
81
75
-
:clock9: This step may take quite a lot of time due to npm's initial modules download
82
+
The database will be automatically set-up thanks to Flask Migrate and any future modification brought to [models](./api/app/model) will be automatically applied when the API is **restarted**.
76
83
77
-
Just run :
84
+
You might wait some time before the database get updated after starting the API :
78
85
79
86
```bash
80
-
# Build is quick, **first** launch is long (expect at least 5 min.)
81
-
docker-compose up app
87
+
docker-compose up --build -d api
82
88
```
83
89
84
-
You can now enjoy the app on [`http://localhost:8080`](http://localhost:8080)
85
-
86
-
> :information_source: If you want to add a dependency, just stop & re-launch a `docker-compose up app`. You won't have to wait as for first launch.
87
-
88
-
## Why using LDAP authentication ?
90
+
> For development, go to [`http://localhost:5000`](http://localhost:5000) to access the API documentation
89
91
90
-
LDAP services are used in a lot of companies and institutions around the world to manage their user accounts and rights in a central place.
92
+
### 5. Run the web application
91
93
92
-
With this boilerplate, you will be able to develop corporate-ready services AND avoid yourself the troubles of developing registration / password forgotten / change password / profile update code.
94
+
:clock9: NPM's initial install may take quite a lot of time
93
95
94
-
## Left TODOs
96
+
Start the app :
95
97
96
-
API :
98
+
```bash
99
+
# Expect several minutes for first launch (npm install)
100
+
docker-compose up --build -d app
101
+
```
97
102
98
-
_Completed_
103
+
You can now enjoy the app on [`http://localhost:8080`](http://localhost:8080)
99
104
100
-
App :
105
+
> :information_source: If you want to add a NPM package, just stop & re-launch `docker-compose up app`.
101
106
102
-
_Completed_
107
+
## Why using LDAP authentication ?
103
108
104
-
Architecture :
109
+
LDAP services are used in a lot of companies and institutions around the world to manage their user accounts and rights in a central place.
105
110
106
-
-[P3] Add "Deploy to prod" guide in README
107
-
-[P3] Create a `prod.docker-compose.yml` file that :
108
-
- Uses NGINX with SSL
109
-
- Builds & serves the front-end
110
-
- Disables Swagger UI
111
+
With this boilerplate, you will be able to develop corporate-ready services AND avoid yourself the troubles of developing registration / password forgotten / change password / profile update code.
0 commit comments