|
11 | 11 | * See the License for the specific language governing permissions and |
12 | 12 | * limitations under the License. |
13 | 13 | **/ |
| 14 | +use App\libs\OAuth2\IUserScopes; |
14 | 15 | use App\Services\Auth\IStreamChatSSOService; |
15 | 16 | use Illuminate\Support\Facades\Log; |
16 | 17 | use models\exceptions\EntityNotFoundException; |
17 | 18 | use models\exceptions\ValidationException; |
18 | 19 | use OAuth2\IResourceServerContext; |
| 20 | +use OpenApi\Attributes as OA; |
| 21 | +use Symfony\Component\HttpFoundation\Response as HttpResponse; |
19 | 22 | use Utils\Services\ILogService; |
20 | 23 | /** |
21 | 24 | * Class OAuth2StreamChatSSOApiController |
@@ -44,6 +47,50 @@ public function __construct |
44 | 47 | * @param string $forum_slug |
45 | 48 | * @return \Illuminate\Http\JsonResponse|mixed |
46 | 49 | */ |
| 50 | + #[OA\Get( |
| 51 | + path: '/api/v1/sso/stream-chat/{forum_slug}/profile', |
| 52 | + operationId: 'getStreamChatUserProfile', |
| 53 | + summary: 'Get Stream Chat user profile for a forum', |
| 54 | + description: 'Returns the Stream Chat user profile and authentication token for the given forum. Requires SSO scope.', |
| 55 | + security: [['OAuth2StreamChatSSOSecurity' => [IUserScopes::SSO]]], |
| 56 | + tags: ['Stream Chat SSO'], |
| 57 | + parameters: [ |
| 58 | + new OA\Parameter( |
| 59 | + name: 'forum_slug', |
| 60 | + description: 'Forum slug', |
| 61 | + in: 'path', |
| 62 | + required: true, |
| 63 | + schema: new OA\Schema(type: 'string') |
| 64 | + ), |
| 65 | + ], |
| 66 | + responses: [ |
| 67 | + new OA\Response( |
| 68 | + response: HttpResponse::HTTP_OK, |
| 69 | + description: 'OK', |
| 70 | + content: new OA\JsonContent(ref: '#/components/schemas/StreamChatUserProfile') |
| 71 | + ), |
| 72 | + new OA\Response( |
| 73 | + response: HttpResponse::HTTP_NOT_FOUND, |
| 74 | + description: 'Not Found' |
| 75 | + ), |
| 76 | + new OA\Response( |
| 77 | + response: HttpResponse::HTTP_PRECONDITION_FAILED, |
| 78 | + description: 'Validation Error' |
| 79 | + ), |
| 80 | + new OA\Response( |
| 81 | + response: HttpResponse::HTTP_INTERNAL_SERVER_ERROR, |
| 82 | + description: 'Server Error' |
| 83 | + ), |
| 84 | + new OA\Response( |
| 85 | + response: HttpResponse::HTTP_UNAUTHORIZED, |
| 86 | + description: 'Unauthorized - invalid or missing token' |
| 87 | + ), |
| 88 | + new OA\Response( |
| 89 | + response: HttpResponse::HTTP_FORBIDDEN, |
| 90 | + description: 'Forbidden - insufficient scope' |
| 91 | + ), |
| 92 | + ] |
| 93 | + )] |
47 | 94 | public function getUserProfile(string $forum_slug){ |
48 | 95 | try{ |
49 | 96 | $profile = $this->service->getUserProfile($forum_slug); |
|
0 commit comments