From 0de7f972fe92fd8fe46e71d49a6a4f33f625e8c3 Mon Sep 17 00:00:00 2001 From: Stephane Carrez Date: Sun, 28 Jan 2018 07:55:36 +0100 Subject: [PATCH] Fix the Ada server skeleton to check the authsMethods in the Shared_Instance generic package (#7514) [Ada] fix PUT request and authentication checks for the server skeleton --- .../Ada/server-skeleton-body.mustache | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Ada/server-skeleton-body.mustache b/modules/swagger-codegen/src/main/resources/Ada/server-skeleton-body.mustache index 3af43f5c9f1a..a4e0d8d53c79 100644 --- a/modules/swagger-codegen/src/main/resources/Ada/server-skeleton-body.mustache +++ b/modules/swagger-codegen/src/main/resources/Ada/server-skeleton-body.mustache @@ -33,6 +33,10 @@ package body {{package}}.Skeletons is {{/returnType}} begin {{#authMethods}} + if not Context.Is_Authenticated then + Context.Set_Error (401, "Not authenticated"); + return; + end if; {{#scopes}} if not Context.Has_Permission (ACL_{{ident}}.Permission) then Context.Set_Error (403, "Permission denied"); @@ -48,7 +52,7 @@ package body {{package}}.Skeletons is {{/pathParams}} {{#hasFormParams}} {{#formParams}} - Swagger.Servers.Get_Parameter (Req, "{{baseName}}", {{paramName}}); + Swagger.Servers.Get_Parameter (Context, "{{baseName}}", {{paramName}}); {{/formParams}} {{/hasFormParams}} {{#hasParams}} @@ -122,6 +126,18 @@ package body {{package}}.Skeletons is Result : {{returnType}}; {{/returnType}} begin + {{#authMethods}} + if not Context.Is_Authenticated then + Context.Set_Error (401, "Not authenticated"); + return; + end if; + {{#scopes}} + if not Context.Has_Permission (ACL_{{ident}}.Permission) then + Context.Set_Error (403, "Permission denied"); + return; + end if; + {{/scopes}} + {{/authMethods}} {{#queryParams}} Swagger.Servers.Get_Query_Parameter (Req, "{{baseName}}", {{paramName}}); {{/queryParams}} @@ -130,7 +146,7 @@ package body {{package}}.Skeletons is {{/pathParams}} {{#hasFormParams}} {{#formParams}} - Swagger.Servers.Get_Parameter (Req, "{{baseName}}", {{paramName}}); + Swagger.Servers.Get_Parameter (Context, "{{baseName}}", {{paramName}}); {{/formParams}} {{/hasFormParams}} {{#hasParams}}