Skip to content

Commit

Permalink
Add SQLAlchemy Helpers integration
Browse files Browse the repository at this point in the history
Signed-off-by: Akashdeep Dhar <[email protected]>

Fix the Vagrant environment

Signed-off-by: Aurélien Bompard <[email protected]>

resolve review

delete __init__ and util
  • Loading branch information
gridhead authored and brngylni committed Jul 12, 2024
1 parent 46b596f commit 6b79a7a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 48 deletions.
Empty file.
18 changes: 4 additions & 14 deletions webhook_to_fedora_messaging/endpoints/apikey.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


@apikey_endpoint.route("/apikey", methods=["POST"])
@validate_request(['username', 'valid_till', 'name'])
def create_apikey():
"""Used for creating a new service by sending a post request to /service/ path.
Expand All @@ -22,8 +23,6 @@ def create_apikey():
"""
session = db.Session()
body = request.json
if not validate_request(request, fields=['username', 'valid_till', 'name',]):
return unprocessable_entity()

user = session.query(User).filter(User.username == body['username']).first()
if user is None:
Expand All @@ -39,15 +38,13 @@ def create_apikey():


@apikey_endpoint.route("/apikey/search", methods=["GET"])
@validate_request
def list_apikey():
"""Used for listing all api keys by sending a get request to /apikey/search path.
Request body:
username: Username of the user
"""
if not validate_request(request):
return unprocessable_entity()

session = db.Session()
user = session.query(User).filter(User.username.like(request.json['username'])).first()
if user is None:
Expand All @@ -59,14 +56,13 @@ def list_apikey():


@apikey_endpoint.route("/apikey", methods=["GET"])
@validate_request(['apikey_uuid'])
def lookup_apikey():
"""Used for searching api keys by sending a get request to /apikey path
Request body:
uuid: UUID of the apikey
"""
if not validate_request(request, fields=['uuid']):
return unprocessable_entity

session = db.Session()
apikey = session.query(APIKey).filter(APIKey.id == request.json['apikey_uuid']).first()
Expand All @@ -79,16 +75,14 @@ def lookup_apikey():


@apikey_endpoint.route("/apikey/revoke", methods=["PUT"])
@validate_request
def revoke_service():
"""Used for revoking an api key by sending a PUT request to /apikey/revoke path.
Request body:
username: Username of the user that the api key belongs to.
apikey_uuid: UUID of the api key.
"""
if not validate_request(request):
return unprocessable_entity()

session = db.Session()
user = session.query(User).filter(User.username == request.json['username']).first()
apikey = session.query(APIKey).filter(APIKey.user_id == user.id and APIKey.id == request.json['apikey_uuid']).first()
Expand All @@ -98,8 +92,4 @@ def revoke_service():
apikey.disabled = True
session.commit()
return success({'uuid': apikey.id, 'is_valid': not apikey.disabled})





34 changes: 0 additions & 34 deletions webhook_to_fedora_messaging/endpoints/util.py

This file was deleted.

0 comments on commit 6b79a7a

Please sign in to comment.