From 625a4353374e3e1673c0b0cdb5092d29ee21e5d5 Mon Sep 17 00:00:00 2001 From: Filip Michalski Date: Tue, 15 Oct 2024 14:50:30 +0200 Subject: [PATCH] Update withSecurity endpoint definitions, add examples, remove duplicated 403 definitions --- .../restmodel/BaseEndpointDefinitions.scala | 70 +-- .../ui/api/TestingApiHttpService.scala | 12 - .../api/description/TestingApiEndpoints.scala | 4 +- docs-internal/api/nu-designer-openapi.yaml | 572 ++++++++---------- .../ui/security/api/SecurityError.scala | 14 +- 5 files changed, 277 insertions(+), 395 deletions(-) diff --git a/designer/restmodel/src/main/scala/pl/touk/nussknacker/restmodel/BaseEndpointDefinitions.scala b/designer/restmodel/src/main/scala/pl/touk/nussknacker/restmodel/BaseEndpointDefinitions.scala index f2b4e414301..9e58c8ffd7f 100644 --- a/designer/restmodel/src/main/scala/pl/touk/nussknacker/restmodel/BaseEndpointDefinitions.scala +++ b/designer/restmodel/src/main/scala/pl/touk/nussknacker/restmodel/BaseEndpointDefinitions.scala @@ -10,7 +10,7 @@ import pl.touk.nussknacker.ui.security.api.SecurityError.{ ImpersonationNotSupportedError, InsufficientPermission } -import sttp.model.StatusCode.{Forbidden, NotFound, NotImplemented, Unauthorized} +import sttp.model.StatusCode.{Forbidden, NotImplemented, Unauthorized} import sttp.tapir.EndpointIO.Example import sttp.tapir._ @@ -29,7 +29,6 @@ trait BaseEndpointDefinitions { object BaseEndpointDefinitions { - type EndpointError[ERROR] = Either[SecurityError, ERROR] type SecuredEndpoint[INPUT, BUSINESS_ERROR, OUTPUT, -R] = Endpoint[AuthCredentials, INPUT, Either[BUSINESS_ERROR, SecurityError], OUTPUT, R] @@ -67,37 +66,20 @@ object BaseEndpointDefinitions { ) ) ), - oneOfVariantFromMatchType( - NotFound, - plainBody[ImpersonatedUserDataNotFoundError.type] - .description("Identity provided in the Nu-Impersonate-User-Identity header did not match any user") - .example( - Example.of( - summary = Some("No impersonated user's data found for provided identity"), - value = ImpersonatedUserDataNotFoundError - ) - ) - ), oneOfVariantFromMatchType( Forbidden, - plainBody[ImpersonationMissingPermissionError.type] - .example( - Example.of( - summary = Some("Authorization failed, user does not have permission to impersonate"), - value = ImpersonationMissingPermissionError + oneOfBody[SecurityError]( + plainBody[SecurityError] + .examples( + List( + Example.of(name = Some("InsufficientPermission"), value = InsufficientPermission), + Example + .of(name = Some("ImpersonationMissingPermission"), value = ImpersonationMissingPermissionError), + Example.of(name = Some("ImpersonatedUserDataNotFound"), value = ImpersonatedUserDataNotFoundError) + ) ) - ) + ) ), - oneOfVariantFromMatchType( - Forbidden, - plainBody[InsufficientPermission.type] - .example( - Example.of( - summary = Some("Authorization failed"), - value = InsufficientPermission - ) - ) - ) ) ) } @@ -106,36 +88,16 @@ object BaseEndpointDefinitions { private object Codecs { - implicit val authenticationErrorCodec: Codec[String, CannotAuthenticateUser.type, CodecFormat.TextPlain] = { - Codec.string.map( - Mapping.from[String, CannotAuthenticateUser.type](_ => CannotAuthenticateUser)(_ => - "The supplied authentication is invalid" - ) - ) - } - - implicit val authorizationErrorCodec: Codec[String, InsufficientPermission.type, CodecFormat.TextPlain] = { - Codec.string.map( - Mapping.from[String, InsufficientPermission.type](_ => InsufficientPermission)(_ => - "The supplied authentication is not authorized to access this resource" - ) - ) - } - - implicit val impersonationPermissionErrorCodec - : Codec[String, ImpersonationMissingPermissionError.type, CodecFormat.TextPlain] = { + implicit val authorizationErrorCodec: Codec[String, SecurityError, CodecFormat.TextPlain] = { Codec.string.map( - Mapping.from[String, ImpersonationMissingPermissionError.type](_ => ImpersonationMissingPermissionError)(_ => - ImpersonationMissingPermissionError.errorMessage - ) + Mapping.from[String, SecurityError](_ => InsufficientPermission)(s => s.errorMessage) ) } - implicit val impersonatedDataNotFoundErrorCodec - : Codec[String, ImpersonatedUserDataNotFoundError.type, CodecFormat.TextPlain] = { + implicit val authenticationErrorCodec: Codec[String, CannotAuthenticateUser.type, CodecFormat.TextPlain] = { Codec.string.map( - Mapping.from[String, ImpersonatedUserDataNotFoundError.type](_ => ImpersonatedUserDataNotFoundError)(_ => - ImpersonatedUserDataNotFoundError.errorMessage + Mapping.from[String, CannotAuthenticateUser.type](_ => CannotAuthenticateUser)(_ => + "The supplied authentication is invalid" ) ) } diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/TestingApiHttpService.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/TestingApiHttpService.scala index 431fc594544..ccc47517ee9 100644 --- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/TestingApiHttpService.scala +++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/TestingApiHttpService.scala @@ -207,18 +207,6 @@ object TestingApiHttpService { ) ) - val noProcessingTypeExample: EndpointOutput.OneOfVariant[NoProcessingType] = - oneOfVariantFromMatchType( - NotFound, - plainBody[NoProcessingType] - .example( - Example.of( - summary = Some("ProcessingType type: {processingType} not found"), - value = NoProcessingType("'processingType'") - ) - ) - ) - } } diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/TestingApiEndpoints.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/TestingApiEndpoints.scala index cad8db5b672..b04ef1f1712 100644 --- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/TestingApiEndpoints.scala +++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/TestingApiEndpoints.scala @@ -133,7 +133,7 @@ class TestingApiEndpoints(auth: EndpointInput[AuthCredentials]) extends BaseEndp ) .errorOut( oneOf[TestingError]( - noScenarioExample // TODO + noScenarioExample ) ) .withSecurity(auth) @@ -205,7 +205,7 @@ class TestingApiEndpoints(auth: EndpointInput[AuthCredentials]) extends BaseEndp .errorOut( oneOf[TestingError]( testDataGenerationErrorExample, - noScenarioExample // TODO + noScenarioExample ) ) .withSecurity(auth) diff --git a/docs-internal/api/nu-designer-openapi.yaml b/docs-internal/api/nu-designer-openapi.yaml index 5456908924a..c2250db3083 100644 --- a/docs-internal/api/nu-designer-openapi.yaml +++ b/docs-internal/api/nu-designer-openapi.yaml @@ -93,13 +93,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -200,20 +202,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -285,13 +279,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -403,20 +399,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '500': description: '' @@ -496,20 +484,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '500': description: '' @@ -580,20 +560,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -666,20 +638,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -745,20 +709,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -838,13 +794,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -944,20 +902,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '409': description: '' @@ -1046,13 +996,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -1129,13 +1081,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -1182,13 +1136,23 @@ paths: content: text/plain: schema: - type: string + anyOf: + - type: string + - type: string + - type: string + examples: + Example: + summary: Attempt to migrate scenario which is already archived + value: Cannot migrate, scenario process1 is archived on test. You + have to unarchive scenario on test in order to migrate. '401': description: '' content: text/plain: schema: - type: string + anyOf: + - type: string + - type: string examples: Example: summary: Migration performed by user without sufficient permissions @@ -1201,20 +1165,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -1274,20 +1230,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -1390,13 +1338,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -1559,13 +1509,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -1714,13 +1666,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -1858,13 +1812,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -1906,26 +1862,6 @@ paths: required: true schema: type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ProcessProperties' - examples: - Example: - summary: Proper process properties - value: - additionalFields: - properties: - parallelism: '' - checkpointIntervalInSeconds: '' - numberOfThreads: '2' - spillStateToDisk: 'true' - environment: test - useAsyncInterpretation: '' - metaDataType: StreamMetaData - showDescription: false - required: true responses: '200': description: '' @@ -1965,13 +1901,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -2101,13 +2039,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -2187,20 +2127,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -2267,20 +2199,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -2374,20 +2298,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -2464,20 +2380,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -2540,20 +2448,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -2619,20 +2519,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '500': description: '' @@ -2759,13 +2651,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -2863,13 +2757,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -2974,13 +2870,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -3094,13 +2992,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -3191,20 +3091,12 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource - '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user - content: - text/plain: - schema: - type: string - examples: - Example: - summary: No impersonated user's data found for provided identity + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: value: No impersonated user data found for provided identity '501': description: Impersonation is not supported for defined authentication mechanism @@ -3285,13 +3177,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -3350,7 +3244,7 @@ paths: description: '' '400': description: 'Invalid value for: header Nu-Impersonate-User-Identity, Invalid - value for: path parameter versionId, Invalid value for: body' + value for: path parameter versionId' content: text/plain: schema: @@ -3372,13 +3266,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -3460,13 +3356,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -3525,7 +3423,7 @@ paths: description: '' '400': description: 'Invalid value for: header Nu-Impersonate-User-Identity, Invalid - value for: path parameter scenarioActivityId, Invalid value for: body' + value for: path parameter scenarioActivityId' content: text/plain: schema: @@ -3547,13 +3445,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -3567,7 +3467,9 @@ paths: content: text/plain: schema: - type: string + anyOf: + - type: string + - type: string examples: Example: summary: 'Unable to edit comment for activity with id: {commentId}' @@ -3637,13 +3539,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -3657,7 +3561,9 @@ paths: content: text/plain: schema: - type: string + anyOf: + - type: string + - type: string examples: Example: summary: 'Unable to edit comment for activity with id: {commentId}' @@ -3712,7 +3618,7 @@ paths: description: '' '400': description: 'Invalid value for: header Nu-Impersonate-User-Identity, Invalid - value for: path parameter versionId, Invalid value for: body' + value for: path parameter versionId' content: text/plain: schema: @@ -3734,13 +3640,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -3816,13 +3724,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -3836,7 +3746,9 @@ paths: content: text/plain: schema: - type: string + anyOf: + - type: string + - type: string examples: Example: summary: 'Unable to edit comment for activity with id: {commentId}' @@ -3921,13 +3833,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -4019,13 +3933,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -4337,13 +4253,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -4520,13 +4438,15 @@ paths: schema: type: string examples: - Example: - summary: Authorization failed + InsufficientPermission: value: The supplied authentication is not authorized to access this resource + ImpersonationMissingPermission: + value: The supplied authentication is not authorized to impersonate + ImpersonatedUserDataNotFound: + value: No impersonated user data found for provided identity '404': - description: Identity provided in the Nu-Impersonate-User-Identity header - did not match any user + description: '' content: text/plain: schema: @@ -4643,6 +4563,7 @@ components: type: string status: type: string + const: AVAILABLE Available1: title: Available type: object @@ -4655,6 +4576,7 @@ components: format: int64 status: type: string + const: AVAILABLE BoolParameterEditor: title: BoolParameterEditor type: object @@ -4922,6 +4844,7 @@ components: properties: status: type: string + const: DELETED Deleted1: title: Deleted type: object @@ -4930,6 +4853,7 @@ components: properties: status: type: string + const: DELETED Dict: title: Dict type: object diff --git a/security/src/main/scala/pl/touk/nussknacker/ui/security/api/SecurityError.scala b/security/src/main/scala/pl/touk/nussknacker/ui/security/api/SecurityError.scala index 90dda412e60..9be320d76db 100644 --- a/security/src/main/scala/pl/touk/nussknacker/ui/security/api/SecurityError.scala +++ b/security/src/main/scala/pl/touk/nussknacker/ui/security/api/SecurityError.scala @@ -1,18 +1,26 @@ package pl.touk.nussknacker.ui.security.api -sealed trait SecurityError +sealed trait SecurityError { + val errorMessage: String +} + sealed trait AuthorizationError extends SecurityError sealed trait AuthenticationError extends SecurityError sealed trait ImpersonationAuthenticationError extends AuthenticationError object SecurityError { - case object InsufficientPermission extends AuthorizationError + + case object InsufficientPermission extends AuthorizationError { + val errorMessage = "The supplied authentication is not authorized to access this resource" + } case object ImpersonationMissingPermissionError extends AuthorizationError { val errorMessage = "The supplied authentication is not authorized to impersonate" } - case object CannotAuthenticateUser extends AuthenticationError + case object CannotAuthenticateUser extends AuthenticationError { + val errorMessage = "The supplied authentication is invalid" + } case object ImpersonatedUserDataNotFoundError extends ImpersonationAuthenticationError { val errorMessage = "No impersonated user data found for provided identity"