-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add new endpoint to retrieve member by external id #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| <?php namespace Database\Migrations\Config; | ||
| /** | ||
| * Copyright 2026 OpenStack Foundation | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| **/ | ||
|
|
||
| use Doctrine\Migrations\AbstractMigration; | ||
| use Doctrine\DBAL\Schema\Schema; | ||
| use App\Security\MemberScopes; | ||
| use App\Models\Foundation\Main\IGroup; | ||
|
|
||
| /** | ||
| * Migration to seed the get-member-by-external-id endpoint. | ||
| * | ||
| * Adds: | ||
| * - 1 api_endpoints row (get-member-by-external-id) | ||
| * - 1 endpoint_api_scopes association (ReadMemberData) | ||
| * - 3 endpoint_api_authz_groups rows (super-admins, administrators, summit-front-end-administrators) | ||
| * | ||
| * All INSERTs are idempotent via WHERE NOT EXISTS. | ||
| */ | ||
| final class Version20260410172200 extends AbstractMigration | ||
| { | ||
| use APIEndpointsMigrationHelper; | ||
|
|
||
| private const API_NAME = 'members'; | ||
| private const ENDPOINT_NAME = 'get-member-by-external-id'; | ||
| private const ENDPOINT_ROUTE = '/api/v1/members/external/{external_id}'; | ||
|
|
||
| public function getDescription(): string | ||
| { | ||
| return 'Seed get-member-by-external-id endpoint with scope and authz groups'; | ||
| } | ||
|
|
||
| /** | ||
| * @param Schema $schema | ||
| */ | ||
| public function up(Schema $schema): void | ||
| { | ||
| $scope = MemberScopes::ReadMemberData; | ||
|
|
||
| // 1. Insert the endpoint | ||
| $this->addSql($this->insertEndpoint( | ||
| self::API_NAME, | ||
| self::ENDPOINT_NAME, | ||
| self::ENDPOINT_ROUTE, | ||
| 'GET' | ||
| )); | ||
|
|
||
| // 2. Insert endpoint_api_scopes association | ||
| $this->addSql($this->insertEndpointScope(self::API_NAME, self::ENDPOINT_NAME, $scope)); | ||
|
|
||
| // 3. Insert endpoint_api_authz_groups | ||
| $authzGroups = [ | ||
| IGroup::SuperAdmins, | ||
| IGroup::Administrators, | ||
| IGroup::SummitAdministrators, | ||
| ]; | ||
|
|
||
| foreach ($authzGroups as $groupSlug) { | ||
| $this->addSql($this->insertEndpointAuthzGroup(self::API_NAME, self::ENDPOINT_NAME, $groupSlug)); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param Schema $schema | ||
| */ | ||
| public function down(Schema $schema): void | ||
| { | ||
| $scope = MemberScopes::ReadMemberData; | ||
|
|
||
| // Reverse order: authz groups → endpoint scopes → endpoint | ||
| $authzGroups = [ | ||
| IGroup::SuperAdmins, | ||
| IGroup::Administrators, | ||
| IGroup::SummitAdministrators, | ||
| ]; | ||
|
|
||
| foreach ($authzGroups as $groupSlug) { | ||
| $this->addSql($this->deleteEndpointAuthzGroup(self::API_NAME, self::ENDPOINT_NAME, $groupSlug)); | ||
| } | ||
|
|
||
| $this->addSql($this->deleteScopesEndpoints(self::API_NAME, [$scope])); | ||
| $this->addSql($this->deleteEndpoint(self::API_NAME, self::ENDPOINT_NAME)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,7 +24,11 @@ | |||||||||||||||||
| // members | ||||||||||||||||||
| Route::group(['prefix' => 'members'], function () { | ||||||||||||||||||
| Route::get('', 'OAuth2MembersApiController@getAll'); | ||||||||||||||||||
|
|
||||||||||||||||||
| Route::group(['prefix' => 'external'], function () { | ||||||||||||||||||
| Route::group(['prefix' => '{external_id}'], function () { | ||||||||||||||||||
| Route::get('', ['middleware' => 'auth.user', 'uses' => 'OAuth2MembersApiController@getMemberByIdExternalId']); | ||||||||||||||||||
| }); | ||||||||||||||||||
|
Comment on lines
+27
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Constrain
Suggested change- Route::group(['prefix' => '{external_id}'], function () {
+ Route::group(['prefix' => '{external_id}', 'where' => ['external_id' => '[0-9]+']], function () {
Route::get('', ['middleware' => 'auth.user', 'uses' => 'OAuth2MembersApiController@getMemberByIdExternalId']);
});📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| }); | ||||||||||||||||||
| Route::group(['prefix' => 'me'], function () { | ||||||||||||||||||
| // get my member info | ||||||||||||||||||
| Route::get('', 'OAuth2MembersApiController@getMyMember'); | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use admin/public serialization policy, not private serialization, for cross-member lookup.
This endpoint fetches another member record, but it currently serializes with
SerializerType_Private(self-profile level). That is inconsistent withgetByIdand can overexpose member fields.Suggested change
📝 Committable suggestion
🤖 Prompt for AI Agents