Skip to content

Commit 5b17bc6

Browse files
committed
fix the solana proxy auth
1 parent 7910381 commit 5b17bc6

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aws_packages"
3-
version = "0.0.16"
3+
version = "0.0.17"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

aws_packages/auth/auth_backend_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from aws_packages.auth.models import AuthenticationRequest, User
22

3+
# TODO: use abc abstractmethod
4+
35

46
class AuthBackendBase:
57
"""Base class for authentication backends"""

aws_packages/auth/solana/auth_backend.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ class SolanaAuthBackend(AuthBackendBase):
1313
def __init__(self, url: str):
1414
self._url = url
1515

16-
def authenticate(self, login_request: AuthenticationRequest) -> User:
16+
def authenticate(self, login_request_body: AuthenticationRequest) -> User:
1717
"""Authenticate the request and returns an authenticated User"""
1818

1919
# solana sdk call and authenticate or raise exception
20+
if login_request_body.authcode != "1234":
21+
raise Exception("Invalid authcode")
2022

21-
return User(principal=login_request.user)
23+
return User(principal=login_request_body.user)
2224

2325
def authenticate_with_token(self, token: str):
2426
"""Authenticate user using jwt token and return status"""

aws_packages/auth/solana/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from aws_packages.auth.views import process_authenticate_request
33

44

5-
def process_icp_authenticate_request(request_body):
5+
def process_solana_authenticate_request(request_body):
66
return process_authenticate_request(request_body, solana_auth_backend)

aws_packages/auth/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
from aws_lambda_powertools.event_handler import Response, content_types
55
from aws_lambda_powertools.event_handler.exceptions import BadRequestError
66

7+
from aws_packages.auth.auth_backend_base import AuthBackendBase
78
from aws_packages.auth.models import AuthenticationRequest, LoginResponse
89

910

10-
def process_authenticate_request(request_body, auth_backend):
11+
def process_authenticate_request(request_body, auth_backend: AuthBackendBase):
1112
if request_body is None:
1213
raise BadRequestError("No request body provided")
1314

@@ -16,6 +17,7 @@ def process_authenticate_request(request_body, auth_backend):
1617
try:
1718
auth_user = auth_backend.authenticate(request_obj)
1819
except Exception as e:
20+
# TODO: Raise error instead of response
1921
return Response(
2022
status_code=HTTPStatus.BAD_REQUEST.value,
2123
content_type=content_types.APPLICATION_JSON,

0 commit comments

Comments
 (0)