Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
oauth2: Add OpenAPI spec
Signed-off-by: jld3103 <jld3103yt@gmail.com>
  • Loading branch information
provokateurin committed Jul 3, 2023
commit f7baebb3b30a592242df453e784d055964c6fb3f
18 changes: 12 additions & 6 deletions apps/oauth2/lib/Controller/LoginRedirectorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Kate Döen <kate.doeen@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
Expand All @@ -30,8 +31,8 @@
use OCA\OAuth2\Db\ClientMapper;
use OCA\OAuth2\Exceptions\ClientNotFoundException;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\IRequest;
Expand Down Expand Up @@ -74,14 +75,19 @@ public function __construct(string $appName,
* @NoCSRFRequired
* @UseSession
*
* @param string $client_id
* @param string $state
* @param string $response_type
* @return Response
* Authorize the user
*
* @param string $client_id Client ID
* @param string $state State of the flow
* @param string $response_type Response type for the flow
* @return TemplateResponse<Http::STATUS_OK, array{}>|RedirectResponse<Http::STATUS_SEE_OTHER, array{}>
*
* 200: Client not found
* 303: Redirect to login URL
*/
public function authorize($client_id,
$state,
$response_type): Response {
$response_type) {
try {
$client = $this->clientMapper->getByIdentifier($client_id);
} catch (ClientNotFoundException $e) {
Expand Down
18 changes: 12 additions & 6 deletions apps/oauth2/lib/Controller/OauthApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Kate Döen <kate.doeen@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
Expand Down Expand Up @@ -66,12 +67,17 @@ public function __construct(
* @NoCSRFRequired
* @BruteForceProtection(action=oauth2GetToken)
*
* @param string $grant_type
* @param string $code
* @param string $refresh_token
* @param string $client_id
* @param string $client_secret
* @return JSONResponse
* Get a token
*
* @param string $grant_type Token type that should be granted
* @param string $code Code of the flow
* @param string $refresh_token Refresh token
* @param string $client_id Client ID
* @param string $client_secret Client secret
* @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{}>
*
* 200: Token returned
* 400: Getting token is not possible
*/
public function getToken($grant_type, $code, $refresh_token, $client_id, $client_secret): JSONResponse {

Expand Down
2 changes: 1 addition & 1 deletion apps/oauth2/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scheme": "bearer"
}
},
"schemas": []
"schemas": {}
},
"paths": {
"/index.php/apps/oauth2/authorize": {
Expand Down