Skip to content

Commit

Permalink
fix: catch up to develop (#277)
Browse files Browse the repository at this point in the history
This demo branch is behind develop
  • Loading branch information
anayeaye authored Jan 22, 2024
2 parents 6e61c26 + 8e765e4 commit 9a55ad4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
4 changes: 3 additions & 1 deletion ingest_api/infrastructure/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class IngestorConfig(BaseSettings):

userpool_id: str = Field(description="The Cognito Userpool used for authentication")
client_id: str = Field(description="The Cognito APP client ID")
client_secret: str = Field(description="The Cognito APP client secret")
client_secret: Optional[str] = Field(
"", description="The Cognito APP client secret"
)

stac_db_secret_name: str = Field(
description="Name of secret containing pgSTAC DB connection information"
Expand Down
2 changes: 2 additions & 0 deletions ingest_api/runtime/src/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,6 @@ def authenticate_and_get_token(
return {
"message": "Login failed, please make sure the credentials are correct."
}
except Exception as e:
return {"message": f"Login failed with exception {e}"}
return resp["AuthenticationResult"]
2 changes: 1 addition & 1 deletion ingest_api/runtime/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Settings(BaseSettings):
userpool_id: str = Field(description="The Cognito Userpool used for authentication")

client_id: str = Field(description="The Cognito APP client ID")
client_secret: str = Field(description="The Cognito APP client secret")
client_secret: str = Field("", description="The Cognito APP client secret")
root_path: str = Field(description="Root path of API")
stage: str = Field(description="API stage")

Expand Down
20 changes: 13 additions & 7 deletions ingest_api/runtime/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,19 @@ async def get_token(
"""
Get token from username and password
"""
return auth.authenticate_and_get_token(
form_data.username,
form_data.password,
settings.userpool_id,
settings.client_id,
settings.client_secret,
)
try:
return auth.authenticate_and_get_token(
form_data.username,
form_data.password,
settings.userpool_id,
settings.client_id,
settings.client_secret,
)
except Exception as e:
raise HTTPException(
status_code=500,
detail=(f"Unable to get token: {e}"),
)


@app.get("/auth/me", tags=["Auth"], response_model=schemas.WhoAmIResponse)
Expand Down
20 changes: 4 additions & 16 deletions ingest_api/runtime/src/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
from urllib.parse import urlparse

import src.validators as validators
from pydantic import (
BaseModel,
Field,
PositiveInt,
error_wrappers,
root_validator,
validator,
)
from pydantic import BaseModel, Field, PositiveInt, error_wrappers, validator
from src.schema_helpers import SpatioTemporalExtent
from stac_pydantic import Collection, Item, shared
from stac_pydantic.links import Link
Expand Down Expand Up @@ -63,11 +56,6 @@ class DashboardCollection(Collection):
class Config:
allow_population_by_field_name = True

@root_validator
def check_time_density(cls, values):
validators.time_density_is_valid(values["is_periodic"], values["time_density"])
return values


class Status(str, enum.Enum):
@classmethod
Expand Down Expand Up @@ -102,9 +90,9 @@ class AuthResponse(BaseModel):

class WhoAmIResponse(BaseModel):
sub: str = Field(..., description="A unique identifier for the user")
cognito_groups: List[str] = Field(
..., description="A list of Cognito groups the user belongs to"
)
# cognito_groups: List[str] = Field(
# ..., description="A list of Cognito groups the user belongs to"
# )
iss: str = Field(..., description="The issuer of the token")
client_id: str = Field(..., description="The client ID of the authenticated app")
origin_jti: str = Field(
Expand Down

0 comments on commit 9a55ad4

Please sign in to comment.