Merge pull request #55786 from nextcloud/backport/55776/stable32

[stable32] fix(TextToImage): Set better attribute for routes
pull/55694/head
Marcel Klehr 2025-10-16 09:26:31 +07:00 committed by GitHub
commit e1fa2c15b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 340 additions and 18 deletions

@ -17,7 +17,6 @@ use OCP\AppFramework\Http\Attribute\AnonRateLimit;
use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
@ -54,7 +53,7 @@ class TextToImageApiController extends OCSController {
*
* 200: Returns availability status
*/
#[PublicPage]
#[NoAdminRequired]
#[ApiRoute(verb: 'GET', url: '/is_available', root: '/text2image')]
public function isAvailable(): DataResponse {
return new DataResponse([
@ -75,9 +74,8 @@ class TextToImageApiController extends OCSController {
* 200: Task scheduled successfully
* 412: Scheduling task is not possible
*/
#[PublicPage]
#[NoAdminRequired]
#[UserRateLimit(limit: 20, period: 120)]
#[AnonRateLimit(limit: 5, period: 120)]
#[ApiRoute(verb: 'POST', url: '/schedule', root: '/text2image')]
public function schedule(string $input, string $appId, string $identifier = '', int $numberOfImages = 8): DataResponse {
$task = new Task($input, $appId, $numberOfImages, $this->userId, $identifier);
@ -111,7 +109,7 @@ class TextToImageApiController extends OCSController {
* 200: Task returned
* 404: Task not found
*/
#[PublicPage]
#[NoAdminRequired]
#[BruteForceProtection(action: 'text2image')]
#[ApiRoute(verb: 'GET', url: '/task/{id}', root: '/text2image')]
public function getTask(int $id): DataResponse {
@ -143,7 +141,7 @@ class TextToImageApiController extends OCSController {
* 200: Image returned
* 404: Task or image not found
*/
#[PublicPage]
#[NoAdminRequired]
#[BruteForceProtection(action: 'text2image')]
#[ApiRoute(verb: 'GET', url: '/task/{id}/image/{index}', root: '/text2image')]
public function getImage(int $id, int $index): DataResponse|FileDisplayResponse {

@ -7158,7 +7158,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -7216,6 +7215,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
@ -7228,7 +7255,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -7397,6 +7423,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
@ -7409,7 +7463,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -7553,6 +7606,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
},
@ -7746,7 +7827,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -7873,6 +7953,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}

@ -7158,7 +7158,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -7216,6 +7215,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
@ -7228,7 +7255,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -7397,6 +7423,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
@ -7409,7 +7463,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -7553,6 +7606,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
},
@ -7746,7 +7827,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -7873,6 +7953,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}

@ -10667,7 +10667,6 @@
"core/text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -10725,6 +10724,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
@ -10737,7 +10764,6 @@
"core/text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -10906,6 +10932,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
@ -10918,7 +10972,6 @@
"core/text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -11062,6 +11115,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
},
@ -11255,7 +11336,6 @@
"core/text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -11382,6 +11462,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}