Skip to content

Commit 1c19c56

Browse files
committed
oauth2: Add OpenAPI spec
Signed-off-by: jld3103 <jld3103yt@gmail.com>
1 parent 2cf8d6d commit 1c19c56

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

apps/oauth2/lib/Controller/LoginRedirectorController.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @author Daniel Kesselberg <mail@danielkesselberg.de>
99
* @author Lukas Reschke <lukas@statuscode.ch>
1010
* @author Roeland Jago Douma <roeland@famdouma.nl>
11+
* @author Kate Döen <kate.doeen@nextcloud.com>
1112
*
1213
* @license GNU AGPL version 3 or any later version
1314
*
@@ -30,8 +31,8 @@
3031
use OCA\OAuth2\Db\ClientMapper;
3132
use OCA\OAuth2\Exceptions\ClientNotFoundException;
3233
use OCP\AppFramework\Controller;
34+
use OCP\AppFramework\Http;
3335
use OCP\AppFramework\Http\RedirectResponse;
34-
use OCP\AppFramework\Http\Response;
3536
use OCP\AppFramework\Http\TemplateResponse;
3637
use OCP\IL10N;
3738
use OCP\IRequest;
@@ -74,14 +75,19 @@ public function __construct(string $appName,
7475
* @NoCSRFRequired
7576
* @UseSession
7677
*
77-
* @param string $client_id
78-
* @param string $state
79-
* @param string $response_type
80-
* @return Response
78+
* Authorize the user
79+
*
80+
* @param string $client_id Client ID
81+
* @param string $state State of the flow
82+
* @param string $response_type Response type for the flow
83+
* @return TemplateResponse<Http::STATUS_OK, array{}>|RedirectResponse<Http::STATUS_SEE_OTHER, array{}>
84+
*
85+
* 200: Client not found
86+
* 303: Redirect to login URL
8187
*/
8288
public function authorize($client_id,
8389
$state,
84-
$response_type): Response {
90+
$response_type): TemplateResponse|RedirectResponse {
8591
try {
8692
$client = $this->clientMapper->getByIdentifier($client_id);
8793
} catch (ClientNotFoundException $e) {

apps/oauth2/lib/Controller/OauthApiController.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
99
* @author Lukas Reschke <lukas@statuscode.ch>
1010
* @author Roeland Jago Douma <roeland@famdouma.nl>
11+
* @author Kate Döen <kate.doeen@nextcloud.com>
1112
*
1213
* @license GNU AGPL version 3 or any later version
1314
*
@@ -66,12 +67,17 @@ public function __construct(
6667
* @NoCSRFRequired
6768
* @BruteForceProtection(action=oauth2GetToken)
6869
*
69-
* @param string $grant_type
70-
* @param string $code
71-
* @param string $refresh_token
72-
* @param string $client_id
73-
* @param string $client_secret
74-
* @return JSONResponse
70+
* Get a token
71+
*
72+
* @param string $grant_type Token type that should be granted
73+
* @param string $code Code of the flow
74+
* @param string $refresh_token Refresh token
75+
* @param string $client_id Client ID
76+
* @param string $client_secret Client secret
77+
* @return JSONResponse<Http::STATUS_OK, array{access_token: string, token_type: string, expires_in: int, refresh_token: string, user_id: string}, array{}>|JSONResponse<Http::STATUS_BAD_REQUEST, array{error: string}, array{}>
78+
*
79+
* 200: Token returned
80+
* 400: Getting token is not possible
7581
*/
7682
public function getToken($grant_type, $code, $refresh_token, $client_id, $client_secret): JSONResponse {
7783

apps/oauth2/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scheme": "bearer"
2020
}
2121
},
22-
"schemas": []
22+
"schemas": {}
2323
},
2424
"paths": {
2525
"/index.php/apps/oauth2/authorize": {

0 commit comments

Comments
 (0)