Skip to content

Commit b3e036e

Browse files
committed
Merge branch 'develop'
2 parents c11165d + fcf4364 commit b3e036e

File tree

9 files changed

+44
-13
lines changed

9 files changed

+44
-13
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
## [2.0.4] - 2024-04-25
8+
9+
- [#204](https://github.com/os2display/display-api-service/pull/204)
10+
- Ensured real ip is logged in nginx.
11+
- [#200](https://github.com/os2display/display-api-service/pull/200)
12+
- Updated oidc internal documentation.
13+
- [#205](https://github.com/os2display/display-api-service/pull/205)
14+
- Fixed redirecting post requests.
15+
716
## [2.0.3] - 2024-04-10
817

918
- [#203](https://github.com/os2display/display-api-service/pull/203)

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,16 @@ The internal oidc provider gets that user's name, email and tenants from claims.
128128

129129
The claim keys needed are set in the env variables:
130130

131-
- INTERNAL_OIDC_CLAIM_NAME
132-
- INTERNAL_OIDC_CLAIM_EMAIL
133-
- INTERNAL_OIDC_CLAIM_GROUPS
131+
- `INTERNAL_OIDC_CLAIM_NAME`
132+
- `INTERNAL_OIDC_CLAIM_EMAIL`
133+
- `INTERNAL_OIDC_CLAIM_GROUPS`
134+
135+
The value of the claim with the name that is defined in the env variable `INTERNAL_OIDC_CLAIM_GROUPS` is mapped to
136+
the user's access to tenants in `App\Security\AzureOidcAuthenticator`. The claim field should consist of an array of
137+
names that should follow the following structure `<TENANT_NAME><ROLE_IN_TENANT>`.
138+
`<ROLE_IN_TENANT>` can be `Admin` or `Redaktoer` (editor).
139+
E.g. `Example1Admin` will map to the tenant with name `Example1` with `ROLE_ADMIN`.
140+
If the tenant does not exist it will be created when the user logs in.
134141

135142
### External
136143

config/packages/nelmio_cors.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ nelmio_cors:
88
expose_headers: ['Link']
99
max_age: 3600
1010
paths:
11-
'^/v2/authentication/':
11+
# v1 is added for backwards compatability: See App/Controller/ApiV1RedirectController
12+
'^/(v1|v2)/authentication/':
1213
allow_credentials: true
1314
'^/': null

config/packages/security.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ security:
3333
login_oidc:
3434
pattern: ^/v2/authentication/oidc
3535
security: false
36+
# v1 is added for backwards compatability: See App/Controller/ApiV1RedirectController
3637
api_token_refresh:
37-
pattern: ^/v2/authentication/token/refresh
38+
pattern: ^/(v1|v2)/authentication/token/refresh
3839
stateless: true
3940
refresh_jwt:
4041
provider: user_provider

infrastructure/itkdev/nginx/etc/confd/templates/nginx.conf.tmpl

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ http {
3737
include /etc/nginx/mime.types;
3838
default_type application/octet-stream;
3939

40-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
40+
set_real_ip_from 172.16.0.0/8;
41+
real_ip_recursive on;
42+
real_ip_header X-Forwarded-For;
43+
44+
log_format main '$http_x_real_ip - $remote_user [$time_local] "$request" '
4145
'$status $body_bytes_sent "$http_referer" '
4246
'"$http_user_agent" "$http_x_forwarded_for"';
4347

infrastructure/os2display/nginx/etc/confd/templates/nginx.conf.tmpl

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ http {
3737
include /etc/nginx/mime.types;
3838
default_type application/octet-stream;
3939

40-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
40+
set_real_ip_from 172.16.0.0/8;
41+
real_ip_recursive on;
42+
real_ip_header X-Forwarded-For;
43+
44+
log_format main '$http_x_real_ip - $remote_user [$time_local] "$request" '
4145
'$status $body_bytes_sent "$http_referer" '
4246
'"$http_user_agent" "$http_x_forwarded_for"';
43-
4447
error_log /dev/stderr;
4548
access_log /dev/stdout main;
4649

psalm-baseline.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,8 @@
751751
<code><![CDATA[$theme]]></code>
752752
</NullableReturnStatement>
753753
<PossiblyNullReference>
754-
<code><![CDATA[addLogo]]></code>
755754
<code><![CDATA[removeLogo]]></code>
755+
<code><![CDATA[setLogo]]></code>
756756
<code><![CDATA[setCreatedBy]]></code>
757757
<code><![CDATA[setCssStyles]]></code>
758758
<code><![CDATA[setDescription]]></code>

src/Controller/ApiV1RedirectController.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
88
use Symfony\Component\HttpFoundation\RedirectResponse;
9+
use Symfony\Component\HttpFoundation\Response;
910
use Symfony\Component\Routing\Attribute\Route;
1011

1112
class ApiV1RedirectController extends AbstractController
1213
{
13-
#[Route('/v1/{endpoint}', name: 'app_api_v1_redirect', requirements: ['endpoint' => '.+'], defaults: ['endpoint' => null], methods: ['GET'])]
14+
#[Route('/v1/{endpoint}', name: 'app_api_v1_redirect', requirements: ['endpoint' => '.+'], defaults: ['endpoint' => null])]
1415
public function index(string $endpoint): RedirectResponse
1516
{
16-
return $this->redirect('/v2/'.$endpoint, \Symfony\Component\HttpFoundation\Response::HTTP_MOVED_PERMANENTLY);
17+
return $this->redirect('/v2/'.$endpoint, Response::HTTP_PERMANENTLY_REDIRECT);
1718
}
1819
}

tests/Controller/ApiV1RedirectControllerTest.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
namespace App\Tests\Controller;
66

77
use App\Tests\AbstractBaseApiTestCase;
8+
use Symfony\Component\HttpFoundation\Request;
89

910
class ApiV1RedirectControllerTest extends AbstractBaseApiTestCase
1011
{
1112
public function testIndex()
1213
{
1314
$client = $this->getAuthenticatedClient('ROLE_ADMIN');
14-
$crawler = $client->request('GET', '/v1/screens/01GN9PW2Z03V8VQG7SN6Q9R17H');
15+
$client->request(Request::METHOD_GET, '/v1/screens/01GN9PW2Z03V8VQG7SN6Q9R17H');
1516

16-
$this->assertResponseRedirects('/v2/screens/01GN9PW2Z03V8VQG7SN6Q9R17H', 301);
17+
$this->assertResponseRedirects('/v2/screens/01GN9PW2Z03V8VQG7SN6Q9R17H', 308);
18+
19+
$client->request(Request::METHOD_POST, '/v1/authentication/screen');
20+
21+
$this->assertResponseRedirects('/v2/authentication/screen', 308);
1722
}
1823
}

0 commit comments

Comments
 (0)