Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@ Run the application through the following API calls:

# API Definition

- **Signup Endpoint**
```http request
POST http://nodeIP:30002/signup
```

```console
curl --location --request POST 'nodeIP:30002/signup' --form 'username="test"' --form 'password="data"'
```
Expected output: User Created successfully

- **Login Endpoint**
```http request
POST http://nodeIP:30002/login
Expand Down Expand Up @@ -271,4 +281,4 @@ To clean up the infrastructure, follow these steps:

1. **Delete the Node Group:** Delete the node group associated with your EKS cluster.

2. **Delete the EKS Cluster:** Once the nodes are deleted, you can proceed to delete the EKS cluster itself.
2. **Delete the EKS Cluster:** Once the nodes are deleted, you can proceed to delete the EKS cluster itself.
17 changes: 16 additions & 1 deletion src/auth-service/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,22 @@ def get_db_connection():
port=5432)
return conn


@server.route('/signup', methods=['POST'])
def signup():
# auth_table_name = os.getenv('AUTH_TABLE')
auth_table_name = 'auth_user'
if not request.form['username'] or not request.form['password']:
return 'Please enter valid username and password', 401, {'WWW-Authenticate': 'Basic realm="Login required!"'}

conn = get_db_connection()
cur = conn.cursor()
query = f"INSERT INTO {auth_table_name} (email, password) VALUES ('{request.form['username']}', '{request.form['password']}');"
res = cur.execute(query)
conn.commit()

if res is None:
return 'User created successfully'

@server.route('/login', methods=['POST'])
def login():
auth_table_name = os.getenv('AUTH_TABLE')
Expand Down