Skip to content

Commit ae0ca46

Browse files
authored
Merge branch 'develop' into hotfix/ip-logging
2 parents 2a2c6d8 + 91d8bc2 commit ae0ca46

File tree

7 files changed

+29
-10
lines changed

7 files changed

+29
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.
66

77
- [#204](https://github.com/os2display/display-api-service/pull/204)
88
- Ensured real ip is logged in nginx.
9+
- [#200](https://github.com/os2display/display-api-service/pull/200)
10+
- Updated oidc internal documentation.
11+
- [#205](https://github.com/os2display/display-api-service/pull/205)
12+
- Fixed redirecting post requests.
913

1014
## [2.0.3] - 2024-04-10
1115

README.md

Lines changed: 10 additions & 3 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

psalm-baseline.xml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 7 additions & 2 deletions
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)