|
1 | | -# Flask + Descope Authentication (and a little bit of React) |
| 1 | + |
2 | 2 |
|
3 | | -Using the Python framework Flask + React.js + Descope Python SDK to add and manage basic authentication and roles. The project will feature multiple pages, protected routes, and logout functionality. |
| 3 | +# Flask-React Sample app with Descope Auth |
4 | 4 |
|
5 | | -<br> |
| 5 | +Add Descope's Python SDK to add authentication to a Flask + React.js app. The project will feature multiple pages, protected routes, and logout functionality. |
6 | 6 |
|
7 | | -## Installing Dependencies 🛠️ |
| 7 | +## ⚙️ Setup |
8 | 8 |
|
9 | | -In the root directory of the project, run the following to install all dependencies: ```npm run setup``` |
| 9 | +1. Clone the repository: |
10 | 10 |
|
11 | | -### Client Setup |
| 11 | +``` |
| 12 | +git clone https://github.com/descope-sample-apps/flask-react-sample-app.git |
| 13 | +``` |
12 | 14 |
|
13 | | -1. Create a ```.env``` file in the root directory of the `client` folder and add your Descope [Project ID](https://app.descope.com/settings/project) in the file: ```REACT_APP_PROJECT_ID=YOUR_DESCOPE_PROJECT_ID``` |
| 15 | +2. Install dependencies: |
14 | 16 |
|
15 | | -> **NOTE**: If you're running your flask server on a different port than 5000, change the ```"proxy":"http://127.0.0.1:5000/"``` value to wherever your server is hosted. You can edit the proxy value in your client package.json file. |
| 17 | +``` |
| 18 | +npm run setup |
| 19 | +``` |
16 | 20 |
|
17 | | -<br> |
| 21 | +3. Client Setup |
18 | 22 |
|
19 | | -### Server Setup |
| 23 | +Create a ```.env``` file in the root directory of the `client` folder and add your Descope [Project ID](https://app.descope.com/settings/project) in the file: |
| 24 | + |
| 25 | +``` |
| 26 | +REACT_APP_PROJECT_ID="YOUR_DESCOPE_PROJECT_ID" |
| 27 | +``` |
| 28 | + |
| 29 | +> **NOTE**: If you're running your flask server on a different port than 5000, change the ```"proxy":"http://127.0.0.1:5000/"``` value to wherever your server is hosted. You can edit the proxy value in your client package.json file. |
| 30 | +
|
| 31 | +4. Server Setup |
20 | 32 |
|
21 | 33 | Since this app also showcases roles, it will require you to set them up in the Descope Console. |
22 | 34 |
|
23 | | -1. Create two different [roles]((https://app.descope.com/authorization)) called "teacher" and "student" <br> |
24 | | -2. Create a ```.env``` file in the server folder and add your project id in the file: |
25 | | - ``` |
26 | | - PROJECT_ID="YOUR_DESCOPE_PROJECT_ID" |
27 | | - ``` |
| 35 | +- Create two different [roles]((https://app.descope.com/authorization)) called "teacher" and "student" <br> |
| 36 | +- Create a ```.env``` file in the server folder and add your project id in the file: |
| 37 | +``` |
| 38 | +PROJECT_ID="YOUR_DESCOPE_PROJECT_ID" |
| 39 | +``` |
28 | 40 |
|
29 | | -<br> |
| 41 | +## 🔮 Running the Application |
30 | 42 |
|
31 | | -## Running the Application 💡 |
| 43 | +To run the server: |
32 | 44 |
|
33 | | -Have at least 2 different terminals open, one command for each terminal. Run the following commands in the project root directory. |
34 | | -- To run the server: ```npm run server``` |
35 | | -- To run the client: ```npm run client``` |
| 45 | +``` |
| 46 | +npm run server |
| 47 | +``` |
36 | 48 |
|
37 | | -<br> |
| 49 | +To run the client: |
38 | 50 |
|
39 | | -## Folder Structure 📁 |
| 51 | +``` |
| 52 | +npm run client |
| 53 | +``` |
| 54 | + |
| 55 | +## 📁 Folder Structure |
40 | 56 |
|
41 | 57 | - Server: the server folder contains the flask app and server that will handle session validation |
42 | 58 | - `app.py`: our main flask app |
43 | 59 | - `requirements.txt`: a txt file with a list of our dependencies |
44 | 60 | - Client: our react app |
45 | 61 |
|
46 | | -<br> |
| 62 | +## ⚠️ Issue Reporting |
| 63 | + |
| 64 | +For any issues or suggestions, feel free to open an issue in the GitHub repository. |
47 | 65 |
|
48 | | -## What is going on? 🤔 |
| 66 | +## 📜 License |
49 | 67 |
|
50 | | -### How do I get started with Descope? |
51 | | -If you don't have a Descope project or unsure what a project ID is, check out the [docs](https://docs.descope.com/build/guides/gettingstarted/) |
| 68 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
52 | 69 |
|
53 | | -### What is Flask? |
54 | | -Flask is a light-weight framework written in Python. It's super simple to get your web app started and running using Flask with just a couple of lines. To learn the basics of Flask, check out the official [documentation](https://flask.palletsprojects.com/en/2.3.x/quickstart/)<br> |
55 | 70 |
|
56 | | -### What is React? |
57 | | -React is a JavaScript web framework used to create beautiful user interfaces. To learn the basics of React check out the official [documentation](https://react.dev/learn) |
58 | 71 |
|
59 | 72 |
|
0 commit comments