Skip to content

Commit cd7b72e

Browse files
committed
feat(version): new version public endpoint
GET api/public/v1/version
1 parent 6d23f7f commit cd7b72e

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

app/Providers/RouteServiceProvider.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public function map(Router $router)
8181
Route::pattern('hint', '(access-token|refresh-token)');
8282
Route::pattern('scope_id', '[0-9]+');
8383

84+
$this->mapPublicApiRoutes();
85+
8486
$this->mapApiRoutes();
8587

8688
$this->mapWebRoutes();
@@ -122,4 +124,17 @@ protected function mapApiRoutes()
122124
->group(base_path('routes/api_v2.php'));
123125
}
124126

127+
/**
128+
* Define the "public api" routes for the application.
129+
*
130+
* These routes are public and do not require authentication.
131+
*
132+
* @return void
133+
*/
134+
protected function mapPublicApiRoutes()
135+
{
136+
Route::prefix('api/public/v1')
137+
->group(base_path('routes/api_public.php'));
138+
}
139+
125140
}

routes/api_public.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Copyright 2026 OpenStack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
15+
use Illuminate\Support\Facades\Route;
16+
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Public API Routes
20+
|--------------------------------------------------------------------------
21+
|
22+
| Public API endpoints that do not require authentication.
23+
|
24+
*/
25+
26+
Route::get('/version', function () {
27+
$versionFile = base_path('version.json');
28+
29+
// Check if file exists
30+
if (!file_exists($versionFile)) {
31+
return response()->json(['error' => 'Version information not found'], 404);
32+
}
33+
34+
// Read file contents
35+
$contents = file_get_contents($versionFile);
36+
37+
// Decode JSON
38+
$versionData = json_decode($contents, true);
39+
40+
// Check if JSON is valid or empty
41+
if ($versionData === null && json_last_error() !== JSON_ERROR_NONE) {
42+
return response()->json(['error' => 'Version information malformed'], 412);
43+
}
44+
45+
if (empty($versionData)) {
46+
return response()->json(['error' => 'Version information malformed'], 412);
47+
}
48+
49+
return response()->json($versionData, 200);
50+
});

version.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"service": "openstackid",
3+
"git_sha": "dev",
4+
"git_tag": "dev"
5+
}

0 commit comments

Comments
 (0)