Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions app/Http/Controllers/Api/OAuth2/OAuth2DisqusSSOApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 OAuth2DisqusSSOApiController
* @package App\Http\Controllers\Api\OAuth2
Expand All @@ -40,6 +43,41 @@ public function __construct
$this->service = $service;
}

#[OA\Get(
path: '/api/v1/sso/disqus/{forum_slug}/profile',
operationId: 'getDisqusUserProfile',
summary: 'Get Disqus user profile for a forum',
security: [['OAuth2DisqusSSOSecurity' => [IUserScopes::SSO]]],
tags: ['Disqus 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',
content: new OA\JsonContent(ref: '#/components/schemas/DisqusUserProfileSerialized')
),
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
Expand Down
18 changes: 18 additions & 0 deletions app/Swagger/Models/DisqusUserProfileSerializedSchema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Swagger\schemas;

use OpenApi\Attributes as OA;

#[OA\Schema(
schema: 'DisqusUserProfileSerialized',
type: 'object',
properties: [
new OA\Property(property: 'auth', type: 'string', description: 'string of base64 profile JSON + space + hash + space + timestamp. The base64 encoded profile is a JSON stringfied object containing the user profile information: id, username, email, avatar in that order. The hash is the base64 encoded info signed with public/private keys'),
new OA\Property(property: 'public_key', type: 'string', description: 'Public key'),
],
description: 'Disqus SSO user profile'
)]
class DisqusUserProfileSerializedSchema
{
}
23 changes: 23 additions & 0 deletions app/Swagger/Security/OAuth2DisqusSSOSecuritySchema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Swagger\schemas;

use App\libs\OAuth2\IUserScopes;
use OpenApi\Attributes as OA;

#[OA\SecurityScheme(
securityScheme: 'OAuth2DisqusSSOSecurity',
type: 'oauth2',
description: 'OAuth2 authentication for Disqus SSO endpoints',
flows: [
new OA\Flow(
flow: 'authorizationCode',
authorizationUrl: L5_SWAGGER_CONST_AUTH_URL,
tokenUrl: L5_SWAGGER_CONST_TOKEN_URL,
scopes: [IUserScopes::SSO => 'Single Sign-On access']
),
]
)]
class OAuth2DisqusSSOSecuritySchema
{
}
Loading