diff --git a/api-docs/generated/openapi.json b/api-docs/generated/openapi.json index f840258..5485b62 100644 --- a/api-docs/generated/openapi.json +++ b/api-docs/generated/openapi.json @@ -775,6 +775,119 @@ } } }, + "/uploadDocument/{programid}": { + "post": { + "tags": [ + "document" + ], + "summary": "Upload Document", + "operationId": "upload_document_uploadDocument__programid__post", + "security": [ + { + "JwtBearerAuth": [] + } + ], + "parameters": [ + { + "name": "programid", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "title": "Programid" + } + }, + { + "name": "file_tag", + "in": "query", + "required": false, + "schema": { + "type": "string", + "title": "File Tag" + } + } + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/Body_upload_document_uploadDocument__programid__post" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DocumentFile" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/getDocument/{document_id}": { + "get": { + "tags": [ + "document" + ], + "summary": "Get Document By Id", + "operationId": "get_document_by_id_getDocument__document_id__get", + "security": [ + { + "JwtBearerAuth": [] + } + ], + "parameters": [ + { + "name": "document_id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "title": "Document Id" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DocumentFile" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, "/auth/profile": { "get": { "tags": [ @@ -1542,6 +1655,33 @@ "type": "object", "title": "BenefitDetails" }, + "Body_upload_document_uploadDocument__programid__post": { + "properties": { + "file": { + "type": "string", + "format": "binary", + "title": "File" + } + }, + "type": "object", + "required": [ + "file" + ], + "title": "Body_upload_document_uploadDocument__programid__post" + }, + "DocumentFile": { + "properties": { + "name": { + "type": "string", + "title": "Name" + } + }, + "type": "object", + "required": [ + "name" + ], + "title": "DocumentFile" + }, "ErrorListResponse": { "properties": { "errors": { @@ -1784,7 +1924,6 @@ "enum": [ "oauth2_auth_code" ], - "const": "oauth2_auth_code", "title": "LoginProviderTypes" }, "PhoneNumber": { diff --git a/src/openg2p_portal_api/dependencies.py b/src/openg2p_portal_api/dependencies.py index fa65f73..114e088 100644 --- a/src/openg2p_portal_api/dependencies.py +++ b/src/openg2p_portal_api/dependencies.py @@ -30,8 +30,12 @@ async def __call__( message="Unauthorized. Invalid Auth Provider. ID Type not configured." ) + mapped_res = AuthOauthProviderORM.map_validation_response( + res.model_dump(), id_type_config["token_map"] + ) + partners = await RegIDORM.get_partner_by_reg_id( - id_type_config["g2p_id_type"], res.sub + id_type_config["g2p_id_type"], mapped_res.get("user_id") ) if not partners: raise UnauthorizedError( diff --git a/src/openg2p_portal_api/models/orm/auth_oauth_provider.py b/src/openg2p_portal_api/models/orm/auth_oauth_provider.py index 7132248..b17718d 100644 --- a/src/openg2p_portal_api/models/orm/auth_oauth_provider.py +++ b/src/openg2p_portal_api/models/orm/auth_oauth_provider.py @@ -40,6 +40,7 @@ class AuthOauthProviderORM(BaseORMModel): jwt_assertion_aud: Mapped[Optional[str]] = mapped_column() scope: Mapped[Optional[str]] = mapped_column() + enable_pkce: Mapped[Optional[str]] = mapped_column() code_verifier: Mapped[Optional[str]] = mapped_column() date_format: Mapped[Optional[str]] = mapped_column() company_id: Mapped[Optional[int]] = mapped_column() @@ -154,6 +155,7 @@ def map_auth_provider_to_login_provider(self) -> LoginProvider: response_type=response_type, redirect_uri=self.g2p_portal_oauth_callback_url or "", scope=self.scope, + enable_pkce=self.enable_pkce, code_verifier=self.code_verifier, extra_authorize_parameters=orjson.loads( self.extra_authorize_params or "{}" diff --git a/src/openg2p_portal_api/services/partner_service.py b/src/openg2p_portal_api/services/partner_service.py index 9320fd3..9ce245e 100644 --- a/src/openg2p_portal_api/services/partner_service.py +++ b/src/openg2p_portal_api/services/partner_service.py @@ -31,15 +31,16 @@ async def check_and_create_partner( message="Invalid Auth Provider Configuration. ID Type not configured." ) + validation = AuthOauthProviderORM.map_validation_response( + validation, id_type_config["token_map"] + ) reg_id_res = await RegIDORM.get_partner_by_reg_id( - id_type_config["g2p_id_type"], validation["sub"] + id_type_config["g2p_id_type"], validation["user_id"] ) if not reg_id_res: - id_value = validation["sub"] - validation = AuthOauthProviderORM.map_validation_response( - validation, id_type_config["token_map"] - ) + id_value = validation["user_id"] + name = validation.pop("name", "") partner_dict = { "given_name": name.split(" ")[0],