Skip to content

Commit a5ce35a

Browse files
committed
fix(TextToImage): Set better attribute for routes
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent ea8ab8e commit a5ce35a

File tree

4 files changed

+340
-18
lines changed

4 files changed

+340
-18
lines changed

core/Controller/TextToImageApiController.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use OCP\AppFramework\Http\Attribute\ApiRoute;
1818
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
1919
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
20-
use OCP\AppFramework\Http\Attribute\PublicPage;
2120
use OCP\AppFramework\Http\Attribute\UserRateLimit;
2221
use OCP\AppFramework\Http\DataResponse;
2322
use OCP\AppFramework\Http\FileDisplayResponse;
@@ -54,7 +53,7 @@ public function __construct(
5453
*
5554
* 200: Returns availability status
5655
*/
57-
#[PublicPage]
56+
#[NoAdminRequired]
5857
#[ApiRoute(verb: 'GET', url: '/is_available', root: '/text2image')]
5958
public function isAvailable(): DataResponse {
6059
return new DataResponse([
@@ -75,9 +74,8 @@ public function isAvailable(): DataResponse {
7574
* 200: Task scheduled successfully
7675
* 412: Scheduling task is not possible
7776
*/
78-
#[PublicPage]
77+
#[NoAdminRequired]
7978
#[UserRateLimit(limit: 20, period: 120)]
80-
#[AnonRateLimit(limit: 5, period: 120)]
8179
#[ApiRoute(verb: 'POST', url: '/schedule', root: '/text2image')]
8280
public function schedule(string $input, string $appId, string $identifier = '', int $numberOfImages = 8): DataResponse {
8381
$task = new Task($input, $appId, $numberOfImages, $this->userId, $identifier);
@@ -111,7 +109,7 @@ public function schedule(string $input, string $appId, string $identifier = '',
111109
* 200: Task returned
112110
* 404: Task not found
113111
*/
114-
#[PublicPage]
112+
#[NoAdminRequired]
115113
#[BruteForceProtection(action: 'text2image')]
116114
#[ApiRoute(verb: 'GET', url: '/task/{id}', root: '/text2image')]
117115
public function getTask(int $id): DataResponse {
@@ -143,7 +141,7 @@ public function getTask(int $id): DataResponse {
143141
* 200: Image returned
144142
* 404: Task or image not found
145143
*/
146-
#[PublicPage]
144+
#[NoAdminRequired]
147145
#[BruteForceProtection(action: 'text2image')]
148146
#[ApiRoute(verb: 'GET', url: '/task/{id}/image/{index}', root: '/text2image')]
149147
public function getImage(int $id, int $index): DataResponse|FileDisplayResponse {

core/openapi-full.json

Lines changed: 112 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7199,7 +7199,6 @@
71997199
"text_to_image_api"
72007200
],
72017201
"security": [
7202-
{},
72037202
{
72047203
"bearer_auth": []
72057204
},
@@ -7257,6 +7256,34 @@
72577256
}
72587257
}
72597258
}
7259+
},
7260+
"401": {
7261+
"description": "Current user is not logged in",
7262+
"content": {
7263+
"application/json": {
7264+
"schema": {
7265+
"type": "object",
7266+
"required": [
7267+
"ocs"
7268+
],
7269+
"properties": {
7270+
"ocs": {
7271+
"type": "object",
7272+
"required": [
7273+
"meta",
7274+
"data"
7275+
],
7276+
"properties": {
7277+
"meta": {
7278+
"$ref": "#/components/schemas/OCSMeta"
7279+
},
7280+
"data": {}
7281+
}
7282+
}
7283+
}
7284+
}
7285+
}
7286+
}
72607287
}
72617288
}
72627289
}
@@ -7269,7 +7296,6 @@
72697296
"text_to_image_api"
72707297
],
72717298
"security": [
7272-
{},
72737299
{
72747300
"bearer_auth": []
72757301
},
@@ -7438,6 +7464,34 @@
74387464
}
74397465
}
74407466
}
7467+
},
7468+
"401": {
7469+
"description": "Current user is not logged in",
7470+
"content": {
7471+
"application/json": {
7472+
"schema": {
7473+
"type": "object",
7474+
"required": [
7475+
"ocs"
7476+
],
7477+
"properties": {
7478+
"ocs": {
7479+
"type": "object",
7480+
"required": [
7481+
"meta",
7482+
"data"
7483+
],
7484+
"properties": {
7485+
"meta": {
7486+
"$ref": "#/components/schemas/OCSMeta"
7487+
},
7488+
"data": {}
7489+
}
7490+
}
7491+
}
7492+
}
7493+
}
7494+
}
74417495
}
74427496
}
74437497
}
@@ -7450,7 +7504,6 @@
74507504
"text_to_image_api"
74517505
],
74527506
"security": [
7453-
{},
74547507
{
74557508
"bearer_auth": []
74567509
},
@@ -7594,6 +7647,34 @@
75947647
}
75957648
}
75967649
}
7650+
},
7651+
"401": {
7652+
"description": "Current user is not logged in",
7653+
"content": {
7654+
"application/json": {
7655+
"schema": {
7656+
"type": "object",
7657+
"required": [
7658+
"ocs"
7659+
],
7660+
"properties": {
7661+
"ocs": {
7662+
"type": "object",
7663+
"required": [
7664+
"meta",
7665+
"data"
7666+
],
7667+
"properties": {
7668+
"meta": {
7669+
"$ref": "#/components/schemas/OCSMeta"
7670+
},
7671+
"data": {}
7672+
}
7673+
}
7674+
}
7675+
}
7676+
}
7677+
}
75977678
}
75987679
}
75997680
},
@@ -7787,7 +7868,6 @@
77877868
"text_to_image_api"
77887869
],
77897870
"security": [
7790-
{},
77917871
{
77927872
"bearer_auth": []
77937873
},
@@ -7914,6 +7994,34 @@
79147994
}
79157995
}
79167996
}
7997+
},
7998+
"401": {
7999+
"description": "Current user is not logged in",
8000+
"content": {
8001+
"application/json": {
8002+
"schema": {
8003+
"type": "object",
8004+
"required": [
8005+
"ocs"
8006+
],
8007+
"properties": {
8008+
"ocs": {
8009+
"type": "object",
8010+
"required": [
8011+
"meta",
8012+
"data"
8013+
],
8014+
"properties": {
8015+
"meta": {
8016+
"$ref": "#/components/schemas/OCSMeta"
8017+
},
8018+
"data": {}
8019+
}
8020+
}
8021+
}
8022+
}
8023+
}
8024+
}
79178025
}
79188026
}
79198027
}

core/openapi.json

Lines changed: 112 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7199,7 +7199,6 @@
71997199
"text_to_image_api"
72007200
],
72017201
"security": [
7202-
{},
72037202
{
72047203
"bearer_auth": []
72057204
},
@@ -7257,6 +7256,34 @@
72577256
}
72587257
}
72597258
}
7259+
},
7260+
"401": {
7261+
"description": "Current user is not logged in",
7262+
"content": {
7263+
"application/json": {
7264+
"schema": {
7265+
"type": "object",
7266+
"required": [
7267+
"ocs"
7268+
],
7269+
"properties": {
7270+
"ocs": {
7271+
"type": "object",
7272+
"required": [
7273+
"meta",
7274+
"data"
7275+
],
7276+
"properties": {
7277+
"meta": {
7278+
"$ref": "#/components/schemas/OCSMeta"
7279+
},
7280+
"data": {}
7281+
}
7282+
}
7283+
}
7284+
}
7285+
}
7286+
}
72607287
}
72617288
}
72627289
}
@@ -7269,7 +7296,6 @@
72697296
"text_to_image_api"
72707297
],
72717298
"security": [
7272-
{},
72737299
{
72747300
"bearer_auth": []
72757301
},
@@ -7438,6 +7464,34 @@
74387464
}
74397465
}
74407466
}
7467+
},
7468+
"401": {
7469+
"description": "Current user is not logged in",
7470+
"content": {
7471+
"application/json": {
7472+
"schema": {
7473+
"type": "object",
7474+
"required": [
7475+
"ocs"
7476+
],
7477+
"properties": {
7478+
"ocs": {
7479+
"type": "object",
7480+
"required": [
7481+
"meta",
7482+
"data"
7483+
],
7484+
"properties": {
7485+
"meta": {
7486+
"$ref": "#/components/schemas/OCSMeta"
7487+
},
7488+
"data": {}
7489+
}
7490+
}
7491+
}
7492+
}
7493+
}
7494+
}
74417495
}
74427496
}
74437497
}
@@ -7450,7 +7504,6 @@
74507504
"text_to_image_api"
74517505
],
74527506
"security": [
7453-
{},
74547507
{
74557508
"bearer_auth": []
74567509
},
@@ -7594,6 +7647,34 @@
75947647
}
75957648
}
75967649
}
7650+
},
7651+
"401": {
7652+
"description": "Current user is not logged in",
7653+
"content": {
7654+
"application/json": {
7655+
"schema": {
7656+
"type": "object",
7657+
"required": [
7658+
"ocs"
7659+
],
7660+
"properties": {
7661+
"ocs": {
7662+
"type": "object",
7663+
"required": [
7664+
"meta",
7665+
"data"
7666+
],
7667+
"properties": {
7668+
"meta": {
7669+
"$ref": "#/components/schemas/OCSMeta"
7670+
},
7671+
"data": {}
7672+
}
7673+
}
7674+
}
7675+
}
7676+
}
7677+
}
75977678
}
75987679
}
75997680
},
@@ -7787,7 +7868,6 @@
77877868
"text_to_image_api"
77887869
],
77897870
"security": [
7790-
{},
77917871
{
77927872
"bearer_auth": []
77937873
},
@@ -7914,6 +7994,34 @@
79147994
}
79157995
}
79167996
}
7997+
},
7998+
"401": {
7999+
"description": "Current user is not logged in",
8000+
"content": {
8001+
"application/json": {
8002+
"schema": {
8003+
"type": "object",
8004+
"required": [
8005+
"ocs"
8006+
],
8007+
"properties": {
8008+
"ocs": {
8009+
"type": "object",
8010+
"required": [
8011+
"meta",
8012+
"data"
8013+
],
8014+
"properties": {
8015+
"meta": {
8016+
"$ref": "#/components/schemas/OCSMeta"
8017+
},
8018+
"data": {}
8019+
}
8020+
}
8021+
}
8022+
}
8023+
}
8024+
}
79178025
}
79188026
}
79198027
}

0 commit comments

Comments
 (0)