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
This commit is contained in:
Stephane Carrez 2018-01-28 07:55:36 +01:00 committed by William Cheng
parent 4bd8fc6e8a
commit 0de7f972fe

View File

@ -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}}