From 85517b5faf31b5fa130864ad377f1612a66eb54e Mon Sep 17 00:00:00 2001 From: matiasperrone-exo Date: Tue, 17 Feb 2026 21:32:34 +0000 Subject: [PATCH 1/3] feat: Add OpenAPI documentation for OAuth2RocketChatSSOApiController v1 api routes --- .../OAuth2RocketChatSSOApiController.php | 43 +++++++++++++++++++ .../Models/RocketChatUserProfileSchema.php | 16 +++++++ ...cketChatSSOApiControllerSecuritySchema.php | 23 ++++++++++ 3 files changed, 82 insertions(+) create mode 100644 app/Swagger/Models/RocketChatUserProfileSchema.php create mode 100644 app/Swagger/Security/OAuth2RocketChatSSOApiControllerSecuritySchema.php diff --git a/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php b/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php index 8e7d82cb..60d8ad04 100644 --- a/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php +++ b/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php @@ -17,6 +17,9 @@ use models\exceptions\ValidationException; use OAuth2\IResourceServerContext; use Utils\Services\ILogService; +use App\libs\OAuth2\IUserScopes; +use OpenApi\Attributes as OA; +use Symfony\Component\HttpFoundation\Response as HttpResponse; /** * Class OAuth2RocketChatSSOApiController * @package App\Http\Controllers\Api\OAuth2 @@ -39,6 +42,46 @@ public function __construct $this->service = $service; } + + #[OA\Get( + path: '/api/v1/sso/rocket-chat/{forum_slug}/profile', + operationId: 'getRocketChatUserProfile', + summary: 'Get Rocket Chat user profile for a forum.', + description: 'Returns Rocket Chat user profile data for the authenticated user in the context of the specified forum. The content of the response is defined by "data" portion of the Rocket Chat login endpoint response structure', + security: [['OAuth2RocketChatSSOSecurity' => [IUserScopes::SSO]]], + tags: ['Rocket Chat SSO'], + parameters: [ + new OA\Parameter( + name: 'forum_slug', + description: 'Forum slug', + in: 'path', + required: true, + schema: new OA\Schema(type: 'string') + ), + ], + responses: [ + new OA\Response( + response: HttpResponse::HTTP_OK, + description: 'OK, returns Rocket Chat user profile data on login success', + content: new OA\JsonContent( + // The content of the response is defined by "data" portion of + // the Rocket Chat login endpoint response structure + ) + ), + new OA\Response( + response: HttpResponse::HTTP_NOT_FOUND, + description: 'Not Found' + ), + new OA\Response( + response: HttpResponse::HTTP_PRECONDITION_FAILED, + description: 'Validation Error' + ), + new OA\Response( + response: HttpResponse::HTTP_INTERNAL_SERVER_ERROR, + description: 'Server Error' + ), + ] + )] /** * @param string $forum_slug * @return \Illuminate\Http\JsonResponse|mixed diff --git a/app/Swagger/Models/RocketChatUserProfileSchema.php b/app/Swagger/Models/RocketChatUserProfileSchema.php new file mode 100644 index 00000000..c5af2f59 --- /dev/null +++ b/app/Swagger/Models/RocketChatUserProfileSchema.php @@ -0,0 +1,16 @@ + 'Single Sign-On access'] + ), + ] +)] +class OAuth2RocketChatSSOApiControllerSecuritySchema +{ +} \ No newline at end of file From 1ac58e225ff4b519a5ea90d2adc60fde0f0591af Mon Sep 17 00:00:00 2001 From: matiasperrone-exo Date: Mon, 23 Feb 2026 19:49:53 +0000 Subject: [PATCH 2/3] chore: Add PR requested changes --- .../OAuth2RocketChatSSOApiController.php | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php b/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php index 60d8ad04..0e6d070d 100644 --- a/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php +++ b/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php @@ -1,4 +1,5 @@ -service = $service; } @@ -66,6 +66,7 @@ public function __construct content: new OA\JsonContent( // The content of the response is defined by "data" portion of // the Rocket Chat login endpoint response structure + red: '#/components/schemas/RocketChatUserProfile', ) ), new OA\Response( @@ -86,21 +87,18 @@ public function __construct * @param string $forum_slug * @return \Illuminate\Http\JsonResponse|mixed */ - public function getUserProfile(string $forum_slug){ - try{ + public function getUserProfile(string $forum_slug) + { + try { $profile = $this->service->getUserProfile($forum_slug); return $this->ok($profile->serialize()); - } - catch (ValidationException $ex) { + } catch (ValidationException $ex) { Log::warning($ex); return $this->error412([$ex->getMessage()]); - } - catch(EntityNotFoundException $ex) - { + } catch (EntityNotFoundException $ex) { Log::warning($ex); - return $this->error404(['message'=> $ex->getMessage()]); - } - catch (\Exception $ex) { + return $this->error404(['message' => $ex->getMessage()]); + } catch (\Exception $ex) { Log::error($ex); return $this->error500($ex); } From 23ee8d2ff952b33486a7814568e62ad19d2b6889 Mon Sep 17 00:00:00 2001 From: matiasperrone-exo Date: Tue, 24 Feb 2026 19:39:34 +0000 Subject: [PATCH 3/3] chore: Add PR requested changes --- .../Api/OAuth2/OAuth2RocketChatSSOApiController.php | 2 +- app/Swagger/Models/RocketChatUserProfileSchema.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php b/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php index 0e6d070d..5dd648ff 100644 --- a/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php +++ b/app/Http/Controllers/Api/OAuth2/OAuth2RocketChatSSOApiController.php @@ -66,7 +66,7 @@ public function __construct content: new OA\JsonContent( // The content of the response is defined by "data" portion of // the Rocket Chat login endpoint response structure - red: '#/components/schemas/RocketChatUserProfile', + ref: '#/components/schemas/RocketChatUserProfile', ) ), new OA\Response( diff --git a/app/Swagger/Models/RocketChatUserProfileSchema.php b/app/Swagger/Models/RocketChatUserProfileSchema.php index c5af2f59..fed4ab0d 100644 --- a/app/Swagger/Models/RocketChatUserProfileSchema.php +++ b/app/Swagger/Models/RocketChatUserProfileSchema.php @@ -7,10 +7,9 @@ #[OA\Schema( schema: 'RocketChatUserProfile', type: 'object', - properties: [ - ], - description: 'Rocket Chat SSO user profile' + additionalProperties: true, + description: 'Rocket Chat SSO user profile. The response structure is the "data" portion of the Rocket Chat /api/v1/login endpoint response and is defined by the external Rocket Chat server.' )] class RocketChatUserProfileSchema { -} +} \ No newline at end of file