Skip to content

Commit 5424bd5

Browse files
committed
chore: pr review
1 parent cff665b commit 5424bd5

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitSponsorApiController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3209,7 +3209,7 @@ public function deleteSocialNetwork($summit_id, $sponsor_id, $social_network_id)
32093209

32103210
#[OA\Get(
32113211
path: "/api/v1/summits/{id}/sponsors/{sponsor_id}/extra-questions",
3212-
description: "required-groups " . IGroup::SuperAdmins . ", " . IGroup::Administrators . ", " . IGroup::SummitAdministrators . ", " . IGroup::Sponsors,
3212+
description: "required-groups " . IGroup::SuperAdmins . ", " . IGroup::Administrators . ", " . IGroup::SummitAdministrators . ", " . IGroup::Sponsors . ", " . IGroup::SponsorExternalUsers,
32133213
summary: 'Read Sponsor Extra Questions',
32143214
operationId: 'getSponsorExtraQuestions',
32153215
tags: ['Sponsors'],
@@ -3424,6 +3424,7 @@ public function getMetadata($summit_id)
34243424
[
34253425
'summit_sponsor_oauth2' => [
34263426
SummitScopes::WriteSummitData,
3427+
SummitScopes::WriteSponsorExtraQuestions,
34273428
]
34283429
]
34293430
],

database/migrations/config/APIEndpointsMigrationHelper.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ trait APIEndpointsMigrationHelper
3939
* @param string $apiName API identifier (e.g., 'summits')
4040
* @param string $endpointName Endpoint identifier (e.g., 'get-sponsor-extra-questions')
4141
* @param string $route Route pattern (e.g., '/api/v1/summits/{id}/sponsors/{sponsor_id}/extra-questions')
42-
* @param string $httpMethod HTTP method as serialized PHP array (e.g., 'a:1:{i:0;s:3:"GET";}')
42+
* @param string $httpMethod Plain HTTP method string (e.g., 'GET', 'POST', 'PUT', 'DELETE')
4343
* @param bool $active Whether the endpoint is active (default: true)
44-
* @param bool $allowCors Whether to allow CORS (default: false)
45-
* @param bool $allowCredentials Whether to allow credentials (default: false)
44+
* @param bool $allowCors Whether to allow CORS (default: true, matches seedApiEndpoints behavior)
45+
* @param bool $allowCredentials Whether to allow credentials (default: true, matches seedApiEndpoints behavior)
4646
* @return string SQL INSERT statement
4747
*/
4848
protected function insertEndpoint(
@@ -51,8 +51,8 @@ protected function insertEndpoint(
5151
string $route,
5252
string $httpMethod,
5353
bool $active = true,
54-
bool $allowCors = false,
55-
bool $allowCredentials = false
54+
bool $allowCors = true,
55+
bool $allowCredentials = true
5656
): string {
5757
$activeInt = $active ? 1 : 0;
5858
$corsInt = $allowCors ? 1 : 0;
@@ -195,16 +195,22 @@ protected function deleteEndpointAuthzGroup(string $apiName, string $endpointNam
195195
/**
196196
* Generate DELETE for endpoint_api_scopes table (all associations for given scopes).
197197
*
198-
* @param array $scopes List of scope URIs to remove associations for
198+
* Constrained by API to prevent removing associations for other APIs that may
199+
* reuse the same scope URI (api_scopes.name has no global uniqueness constraint).
200+
*
201+
* @param string $apiName API identifier (e.g., 'summits')
202+
* @param array $scopes List of scope URIs to remove associations for
199203
* @return string SQL DELETE statement
200204
*/
201-
protected function deleteScopesEndpoints(array $scopes): string
205+
protected function deleteScopesEndpoints(string $apiName, array $scopes): string
202206
{
203207
$scopeList = "'" . implode("', '", $scopes) . "'";
204208
return <<<SQL
205209
DELETE eas FROM endpoint_api_scopes eas
206210
INNER JOIN api_scopes s ON s.id = eas.scope_id
207-
WHERE s.name IN ({$scopeList});
211+
INNER JOIN apis a ON a.id = s.api_id
212+
WHERE a.name = '{$apiName}'
213+
AND s.name IN ({$scopeList});
208214
SQL;
209215
}
210216

database/migrations/config/Version20260408143000.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function down(Schema $schema): void
102102

103103
// Reverse order: authz groups → endpoint scopes → api scopes
104104
$this->addSql($this->deleteEndpointAuthzGroup(self::API_NAME, 'get-sponsor-extra-questions', $externalGroupSlug));
105-
$this->addSql($this->deleteScopesEndpoints([$readScope, $writeScope]));
105+
$this->addSql($this->deleteScopesEndpoints(self::API_NAME, [$readScope, $writeScope]));
106106
$this->addSql($this->deleteApiScopes(self::API_NAME, [$readScope, $writeScope]));
107107
}
108108
}

0 commit comments

Comments
 (0)