Skip to content

Commit d9b39ba

Browse files
authored
Merge pull request #163 from os2display/feature/openid-connect-code-flow
Code authorization flow
2 parents 9e76bff + 7e410ba commit d9b39ba

File tree

19 files changed

+74
-63
lines changed

19 files changed

+74
-63
lines changed

CHANGELOG.md

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

55
## [Unreleased]
66

7+
- [#163](https://github.com/os2display/display-api-service/pull/163)
8+
Upgraded `itk-dev/openid-connect-bundle` to use code authorization flow. Updated OpenAPI spec accordingly.
9+
710
## [1.4.0] - 2023-09-14
11+
812
- [#160](https://github.com/os2display/display-api-service/pull/160)
913
Added app:feed:list-feed-source command. Removed listing from app:feed:remove-feed-source command.
1014
- [#159](https://github.com/os2display/display-api-service/pull/159)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ You can now obtain a token by sending a `POST` request to the
6161

6262
```curl
6363
curl -X 'POST' \
64-
'http://displayapiservice.local.itkdev.dk/authentication/token' \
64+
'http://displayapiservice.local.itkdev.dk/v1/authentication/token' \
6565
-H 'accept: application/json' \
6666
-H 'Content-Type: application/json' \
6767
-d '{
@@ -159,4 +159,4 @@ act -P ubuntu-latest=shivammathur/node:latest pull_request
159159

160160
We use [SemVer](http://semver.org/) for versioning.
161161
For the versions available, see the
162-
[tags on this repository](https://github.com/itk-dev/openid-connect/tags).
162+
[tags on this repository](https://github.com/os2display/display-api-service/tags).

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"doctrine/doctrine-migrations-bundle": "^3.1",
1818
"doctrine/orm": "^2.9",
1919
"gesdinet/jwt-refresh-token-bundle": "^1.0",
20-
"itk-dev/openid-connect-bundle": "^2.0",
20+
"itk-dev/openid-connect-bundle": "^3.0",
2121
"justinrainbow/json-schema": "^5.2",
2222
"kubawerlos/php-cs-fixer-custom-fixers": "^3.11",
2323
"lexik/jwt-authentication-bundle": "^2.14",

composer.lock

Lines changed: 27 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/packages/itkdev_openid_connect.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ itkdev_openid_connect:
22
cache_options:
33
cache_pool: 'cache.app' # Cache item pool for caching discovery document and CLI login tokens
44
cli_login_options:
5-
cli_redirect: '%env(CLI_REDIRECT)%' # Redirect route for CLI login
5+
route: '%env(CLI_REDIRECT)%' # Redirect route for CLI login
66
openid_providers:
77
# Define one or more providers
88
# [providerKey]:

public/api-spec-v1.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
],
2424
"responses": {
2525
"200": {
26-
"description": "Get JWT token from OIDC token",
26+
"description": "Get JWT token from OIDC code",
2727
"content": {
2828
"application/json": {
2929
"schema": {
@@ -33,7 +33,7 @@
3333
}
3434
}
3535
},
36-
"summary": "Get JWT token to login from OIDC token",
36+
"summary": "Get JWT token to login from OIDC code",
3737
"description": "",
3838
"parameters": [
3939
{
@@ -47,8 +47,8 @@
4747
}
4848
},
4949
{
50-
"name": "id_token",
51-
"description": "OIDC id token",
50+
"name": "code",
51+
"description": "OIDC code",
5252
"in": "query",
5353
"required": false,
5454
"example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",

public/api-spec-v1.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ paths:
1717
- Authentication
1818
responses:
1919
200:
20-
description: 'Get JWT token from OIDC token'
20+
description: 'Get JWT token from OIDC code'
2121
content:
2222
application/json:
2323
schema:
2424
$ref: '#/components/schemas/Token'
25-
summary: 'Get JWT token to login from OIDC token'
25+
summary: 'Get JWT token to login from OIDC code'
2626
description: ''
2727
parameters:
2828
-
@@ -34,8 +34,8 @@ paths:
3434
schema:
3535
type: string
3636
-
37-
name: id_token
38-
description: 'OIDC id token'
37+
name: code
38+
description: 'OIDC code'
3939
in: query
4040
required: false
4141
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

src/Command/User/AddUserCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
111111
*/
112112
protected function interact(InputInterface $input, OutputInterface $output): void
113113
{
114-
if (null !== $input->getArgument('email') &&
115-
null !== $input->getArgument('password') &&
116-
null !== $input->getArgument('full-name') &&
117-
null !== $input->getArgument('role') &&
118-
null !== $input->getArgument('tenant-keys')
114+
if (null !== $input->getArgument('email')
115+
&& null !== $input->getArgument('password')
116+
&& null !== $input->getArgument('full-name')
117+
&& null !== $input->getArgument('role')
118+
&& null !== $input->getArgument('tenant-keys')
119119
) {
120120
return;
121121
}

src/Controller/AuthOidcController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
#[Route('/v1/authentication/oidc/token', name: 'authentication_oidc_token', methods: ['GET'])]
3333
public function getToken(Request $request): Response
3434
{
35-
if ($request->query->has('state') && $request->query->has('id_token')) {
35+
if ($request->query->has('state') && $request->query->has('code')) {
3636
try {
3737
$passport = $this->oidcAuthenticator->authenticate($request);
3838

@@ -71,7 +71,12 @@ public function getUrls(Request $request, SessionInterface $session): Response
7171
$session->set('oauth2nonce', $nonce);
7272

7373
$data = [
74-
'authorizationUrl' => $provider->getAuthorizationUrl(['state' => $state, 'nonce' => $nonce]),
74+
'authorizationUrl' => $provider->getAuthorizationUrl([
75+
'state' => $state,
76+
'nonce' => $nonce,
77+
'response_type' => 'code',
78+
'scope' => 'openid email profile',
79+
]),
7580
'endSessionUrl' => $provider->getEndSessionUrl(),
7681
];
7782

src/Entity/Tenant/Media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function setSha(string $sha): self
138138
return $this;
139139
}
140140

141-
public function setFile(?File $file = null): self
141+
public function setFile(File $file = null): self
142142
{
143143
$this->file = $file;
144144

0 commit comments

Comments
 (0)