mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
federation: Add OpenAPI spec
Signed-off-by: jld3103 <jld3103yt@gmail.com>
This commit is contained in:
parent
a84fa17c73
commit
d8ce744403
2 changed files with 452 additions and 4 deletions
|
|
@ -30,6 +30,7 @@ namespace OCA\Federation\Controller;
|
|||
|
||||
use OCA\Federation\DbHandler;
|
||||
use OCA\Federation\TrustedServers;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\OCS\OCSForbiddenException;
|
||||
use OCP\AppFramework\OCSController;
|
||||
|
|
@ -79,7 +80,13 @@ class OCSAuthAPIController extends OCSController {
|
|||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
* @throws OCSForbiddenException
|
||||
*
|
||||
* @param string $url URL of the server
|
||||
* @param string $token Token of the server
|
||||
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
|
||||
* @throws OCSForbiddenException Requesting shared secret is not allowed
|
||||
*
|
||||
* 200: Shared secret requested successfully
|
||||
*/
|
||||
public function requestSharedSecretLegacy(string $url, string $token): DataResponse {
|
||||
return $this->requestSharedSecret($url, $token);
|
||||
|
|
@ -91,7 +98,13 @@ class OCSAuthAPIController extends OCSController {
|
|||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
* @throws OCSForbiddenException
|
||||
*
|
||||
* @param string $url URL of the server
|
||||
* @param string $token Token of the server
|
||||
* @return DataResponse<Http::STATUS_OK, array{sharedSecret: string}, array{}>
|
||||
* @throws OCSForbiddenException Getting shared secret is not allowed
|
||||
*
|
||||
* 200: Shared secret returned
|
||||
*/
|
||||
public function getSharedSecretLegacy(string $url, string $token): DataResponse {
|
||||
return $this->getSharedSecret($url, $token);
|
||||
|
|
@ -102,7 +115,13 @@ class OCSAuthAPIController extends OCSController {
|
|||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
* @throws OCSForbiddenException
|
||||
*
|
||||
* @param string $url URL of the server
|
||||
* @param string $token Token of the server
|
||||
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
|
||||
* @throws OCSForbiddenException Requesting shared secret is not allowed
|
||||
*
|
||||
* 200: Shared secret requested successfully
|
||||
*/
|
||||
public function requestSharedSecret(string $url, string $token): DataResponse {
|
||||
if ($this->trustedServers->isTrustedServer($url) === false) {
|
||||
|
|
@ -138,7 +157,13 @@ class OCSAuthAPIController extends OCSController {
|
|||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
* @throws OCSForbiddenException
|
||||
*
|
||||
* @param string $url URL of the server
|
||||
* @param string $token Token of the server
|
||||
* @return DataResponse<Http::STATUS_OK, array{sharedSecret: string}, array{}>
|
||||
* @throws OCSForbiddenException Getting shared secret is not allowed
|
||||
*
|
||||
* 200: Shared secret returned
|
||||
*/
|
||||
public function getSharedSecret(string $url, string $token): DataResponse {
|
||||
if ($this->trustedServers->isTrustedServer($url) === false) {
|
||||
|
|
|
|||
423
apps/federation/openapi.json
Normal file
423
apps/federation/openapi.json
Normal file
|
|
@ -0,0 +1,423 @@
|
|||
{
|
||||
"openapi": "3.0.3",
|
||||
"info": {
|
||||
"title": "federation",
|
||||
"version": "0.0.1",
|
||||
"description": "Federation allows you to connect with other trusted servers to exchange the user directory.",
|
||||
"license": {
|
||||
"name": "agpl"
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"basic_auth": {
|
||||
"type": "http",
|
||||
"scheme": "basic"
|
||||
},
|
||||
"bearer_auth": {
|
||||
"type": "http",
|
||||
"scheme": "bearer"
|
||||
}
|
||||
},
|
||||
"schemas": {
|
||||
"OCSMeta": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"status",
|
||||
"statuscode"
|
||||
],
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"statuscode": {
|
||||
"type": "integer"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"totalitems": {
|
||||
"type": "string"
|
||||
},
|
||||
"itemsperpage": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/ocs/v2.php/apps/federation/api/v1/shared-secret": {
|
||||
"get": {
|
||||
"operationId": "ocs_authapi-get-shared-secret-legacy",
|
||||
"summary": "Create shared secret and return it, for legacy end-points",
|
||||
"tags": [
|
||||
"ocs_authapi"
|
||||
],
|
||||
"security": [
|
||||
{},
|
||||
{
|
||||
"bearer_auth": []
|
||||
},
|
||||
{
|
||||
"basic_auth": []
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "url",
|
||||
"in": "query",
|
||||
"description": "URL of the server",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "token",
|
||||
"in": "query",
|
||||
"description": "Token of the server",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "OCS-APIRequest",
|
||||
"in": "header",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": "true"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Shared secret returned",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ocs"
|
||||
],
|
||||
"properties": {
|
||||
"ocs": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"meta",
|
||||
"data"
|
||||
],
|
||||
"properties": {
|
||||
"meta": {
|
||||
"$ref": "#/components/schemas/OCSMeta"
|
||||
},
|
||||
"data": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"sharedSecret"
|
||||
],
|
||||
"properties": {
|
||||
"sharedSecret": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Getting shared secret is not allowed",
|
||||
"content": {
|
||||
"text/plain": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/ocs/v2.php/apps/federation/api/v1/request-shared-secret": {
|
||||
"post": {
|
||||
"operationId": "ocs_authapi-request-shared-secret-legacy",
|
||||
"summary": "Request received to ask remote server for a shared secret, for legacy end-points",
|
||||
"tags": [
|
||||
"ocs_authapi"
|
||||
],
|
||||
"security": [
|
||||
{},
|
||||
{
|
||||
"bearer_auth": []
|
||||
},
|
||||
{
|
||||
"basic_auth": []
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "url",
|
||||
"in": "query",
|
||||
"description": "URL of the server",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "token",
|
||||
"in": "query",
|
||||
"description": "Token of the server",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "OCS-APIRequest",
|
||||
"in": "header",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": "true"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Shared secret requested successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ocs"
|
||||
],
|
||||
"properties": {
|
||||
"ocs": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"meta",
|
||||
"data"
|
||||
],
|
||||
"properties": {
|
||||
"meta": {
|
||||
"$ref": "#/components/schemas/OCSMeta"
|
||||
},
|
||||
"data": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Requesting shared secret is not allowed",
|
||||
"content": {
|
||||
"text/plain": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/ocs/v2.php/cloud/shared-secret": {
|
||||
"get": {
|
||||
"operationId": "ocs_authapi-get-shared-secret",
|
||||
"summary": "Create shared secret and return it",
|
||||
"tags": [
|
||||
"ocs_authapi"
|
||||
],
|
||||
"security": [
|
||||
{},
|
||||
{
|
||||
"bearer_auth": []
|
||||
},
|
||||
{
|
||||
"basic_auth": []
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "url",
|
||||
"in": "query",
|
||||
"description": "URL of the server",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "token",
|
||||
"in": "query",
|
||||
"description": "Token of the server",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "OCS-APIRequest",
|
||||
"in": "header",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": "true"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Shared secret returned",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ocs"
|
||||
],
|
||||
"properties": {
|
||||
"ocs": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"meta",
|
||||
"data"
|
||||
],
|
||||
"properties": {
|
||||
"meta": {
|
||||
"$ref": "#/components/schemas/OCSMeta"
|
||||
},
|
||||
"data": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"sharedSecret"
|
||||
],
|
||||
"properties": {
|
||||
"sharedSecret": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Getting shared secret is not allowed",
|
||||
"content": {
|
||||
"text/plain": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"operationId": "ocs_authapi-request-shared-secret",
|
||||
"summary": "Request received to ask remote server for a shared secret",
|
||||
"tags": [
|
||||
"ocs_authapi"
|
||||
],
|
||||
"security": [
|
||||
{},
|
||||
{
|
||||
"bearer_auth": []
|
||||
},
|
||||
{
|
||||
"basic_auth": []
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "url",
|
||||
"in": "query",
|
||||
"description": "URL of the server",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "token",
|
||||
"in": "query",
|
||||
"description": "Token of the server",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "OCS-APIRequest",
|
||||
"in": "header",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": "true"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Shared secret requested successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ocs"
|
||||
],
|
||||
"properties": {
|
||||
"ocs": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"meta",
|
||||
"data"
|
||||
],
|
||||
"properties": {
|
||||
"meta": {
|
||||
"$ref": "#/components/schemas/OCSMeta"
|
||||
},
|
||||
"data": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Requesting shared secret is not allowed",
|
||||
"content": {
|
||||
"text/plain": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "ocs_authapi",
|
||||
"description": "Class OCSAuthAPI\nOCS API end-points to exchange shared secret between two connected Nextclouds"
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Reference in a new issue