Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8189ed832 | ||
|
|
c0600f527f | ||
|
|
ed6065a6ea |
@@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||||
"features": {
|
"features": {
|
||||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
|
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
|
||||||
|
"ghcr.io/warrenbuckley/codespace-features/sqlite:1": {}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ def url_validator(urls: list[str]) -> list[ParseResult]:
|
|||||||
return parsed_urls
|
return parsed_urls
|
||||||
|
|
||||||
def altcha_validator(altcha_response: AltchaPayload):
|
def altcha_validator(altcha_response: AltchaPayload):
|
||||||
# verified = verify_solution(altcha_response, TEMP_HMAC_KEY)
|
verified = verify_solution(altcha_response, TEMP_HMAC_KEY)
|
||||||
verified = (True, None)
|
|
||||||
if not verified[0]:
|
if not verified[0]:
|
||||||
raise ValueError(f"altcha verification failed: {verified[1]}")
|
raise ValueError(f"altcha verification failed: {verified[1]}")
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -134,13 +134,13 @@ async def signup_form(form_data: Annotated[SignupForm, Form()]):
|
|||||||
raise HTTPException(status_code=409, detail="User already exists")
|
raise HTTPException(status_code=409, detail="User already exists")
|
||||||
|
|
||||||
# create user
|
# create user
|
||||||
create_user(form_data.email, get_password_hash(form_data.password), DB_ENGINE)
|
create_user(form_data.email, get_password_hash(form_data.password.get_secret_value()), DB_ENGINE)
|
||||||
|
|
||||||
@app.get("/altcha-challenge")
|
@app.get("/altcha-challenge")
|
||||||
async def altcha_challenge():
|
async def altcha_challenge():
|
||||||
options = ChallengeOptions(
|
options = ChallengeOptions(
|
||||||
expires=datetime.now() + timedelta(minutes=10),
|
expires=datetime.now() + timedelta(minutes=10),
|
||||||
max_number=100000,
|
max_number=80000,
|
||||||
hmac_key=TEMP_HMAC_KEY
|
hmac_key=TEMP_HMAC_KEY
|
||||||
)
|
)
|
||||||
challenge = create_challenge(options)
|
challenge = create_challenge(options)
|
||||||
@@ -154,24 +154,24 @@ async def simple_login(username: Annotated[str, Form()], password: Annotated[str
|
|||||||
token = generate_auth_token(username)
|
token = generate_auth_token(username)
|
||||||
return {"access_token": token, "token_type": "bearer"}
|
return {"access_token": token, "token_type": "bearer"}
|
||||||
|
|
||||||
@app.post("/altcha-challenge")
|
# @app.post("/altcha-challenge")
|
||||||
async def altcha_verify(payload: Annotated[Base64Str, AfterValidator(altcha_validator)]):
|
# async def altcha_verify(payload: Annotated[Base64Str, AfterValidator(altcha_validator)]):
|
||||||
# if verified, return a JWT for anonymous API access
|
# # if verified, return a JWT for anonymous API access
|
||||||
expiration = datetime.now() + timedelta(days=30)
|
# expiration = datetime.now() + timedelta(days=30)
|
||||||
uuid = uuid4()
|
# uuid = uuid4()
|
||||||
bearer_token = {
|
# bearer_token = {
|
||||||
"iss": "slopserver",
|
# "iss": "slopserver",
|
||||||
"exp": int(expiration.timestamp()),
|
# "exp": int(expiration.timestamp()),
|
||||||
"aud": "slopserver",
|
# "aud": "slopserver",
|
||||||
"sub": str(uuid),
|
# "sub": str(uuid),
|
||||||
"client_id": str(uuid),
|
# "client_id": str(uuid),
|
||||||
"iat": int(datetime.now().timestamp()),
|
# "iat": int(datetime.now().timestamp()),
|
||||||
"jti": str(uuid)
|
# "jti": str(uuid)
|
||||||
}
|
# }
|
||||||
|
|
||||||
encoded_jwt = jwt.encode(bearer_token, TOKEN_SECRET, ALGO)
|
# encoded_jwt = jwt.encode(bearer_token, TOKEN_SECRET, ALGO)
|
||||||
|
|
||||||
return encoded_jwt
|
# return encoded_jwt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user