Skip to content

Commit

Permalink
polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwinator committed Mar 21, 2024
1 parent b670790 commit 433e8e5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions facade-poc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# Hardcoded API key
API_KEY = "TEST-API-KEY"
HEADER_NAME = "X-API-Key"
# First endpoint

# Unsecured endpoint
@app.route('/unsecured', methods=['GET'])
def unsecured():
data = {'message': 'This is an unsecured endpoint.'}
Expand All @@ -18,10 +19,11 @@ def endpoint2():
# Check if API key is provided in the request headers
provided_api_key = request.headers.get(HEADER_NAME)

# API key is invalid, return send unauthorized
if provided_api_key != API_KEY:
return jsonify({'error': 'Unauthorized access. Invalid API key.'}), 401

# API key is valid, return data

data = {'message': 'This is a secured endpoint.'}
return jsonify(data)

Expand Down

0 comments on commit 433e8e5

Please sign in to comment.