067 usrId argument removed from annotations

This commit is contained in:
msyu
2025-03-12 18:00:34 +03:00
parent 459ec9da14
commit 6a9dbf19b4
7 changed files with 40 additions and 21 deletions
+24 -10
View File
@@ -51,7 +51,7 @@
//variables.framework.docs={};
variables.framework.docs.APIName="Deck API";
variables.framework.docs.APIVersion="0.066";
variables.framework.docs.APIVersion="0.067";
variables.framework.globalHeaders = structNew();
variables.framework.globalHeaders["Access-Control-Expose-Headers"] = "Location";
@@ -117,7 +117,8 @@
<cfreturn serviceUrl/>
<cfcatch type="any">
<!--- <cfdump var=#cfcatch#/> --->
<!--- <cfdump var=#serviceUrl#/>
<cfdump var=#cfcatch#/><cfabort/> --->
</cfcatch>
</cftry>
</cfloop>
@@ -175,9 +176,9 @@
} else {
return representationOf("Authorization header expected").withStatus(401);
}
var result="";
try {
var httpService = new http(method = "GET", charset = "utf-8", url = #this.iamServiceUrl#, timeout="3");
var httpService = new http(method = "GET", charset = "utf-8", url = #this.iamServiceUrl#, timeout="5");
httpService.addParam(type = "HEADER", name = "Accept", value = "application/json");
httpService.addParam(type = "HEADER", name = "Authorization", value = "#auth#"); //passthrough
//writedump(this.iamServiceUrl);abort;
@@ -185,8 +186,15 @@
//if (resp.status_code NEQ 200) throw("IDP response not OK");
//writedump(resp);abort;
var prefix = resp.getPrefix();
if (prefix.status_code NEQ 200) throw("IDP response not OK");
var result = prefix.filecontent;
if (prefix.status_code NEQ 200) {
writedump(this.iamServiceUrl);
writedump(resp);
abort;
throw("IDP response not OK");
}
result = prefix.filecontent;
//writedump(result);abort;
} catch (e) {
/*if (fileExists("#GetDirectoryFromPath(GetCurrentTemplatePath())#/etc/local-debug")) { //true for local debug without IDP, etc/* does not go to repository
@@ -194,7 +202,7 @@
*/
//writedump(resp);
//return representationOf( {"exception"=e} );
return representationOf( {"exception"=e, "idpResponse"=result} );//.withStatus(500);
return representationOf( {"exception"=e, "idpResponse"=result} ).withStatus(500);
}
//writeDump(result); abort;
@@ -214,6 +222,8 @@
if (structIsEmpty(usrCustomerInfo)) return representationOf("Cannot find default specification for current user #result#").withStatus(422); //это создает довольно много лишних движений при отладке
arguments.requestArguments.usrId=usrCustomerInfo.usrId; //Integer!
arguments.requestArguments.contragentId=usrCustomerInfo.contragentId; //Integer
arguments.requestArguments.contractId=usrCustomerInfo.contractId; //Integer
arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //Integer
return true;
@@ -339,9 +349,9 @@
<cfset local={}/>
<!--- Во избежании потери времени при отладке временно сделаем создание дефолтового контракта и спецификации, если их нет --->
<!--- *** хватается первый попавшийся контракт и спецификация --->
<cfquery name="local.qGetCustomerInfo">
select u.usr_id, s.specification_id
select u.usr_id, c.contragent_id, c.contract_id, s.specification_id
from usr u
join contract c on (u.contragent_id=c.contragent_id)
join specification s on (c.contract_id=s.contract_id)
@@ -350,7 +360,11 @@
</cfquery>
<!--- <cfdump var=#local.qGetCustomerInfo#/><cfabort/> --->
<cfif local.qGetCustomerInfo.recordCount GT 0>
<cfreturn {"usrId"=#local.qGetCustomerInfo.usr_id#, "specificationId"=#local.qGetCustomerInfo.specification_id#}/>
<cfreturn {"usrId"=#local.qGetCustomerInfo.usr_id#,
"contragentId"=#local.qGetCustomerInfo.specification_id#,
"contractId"=#local.qGetCustomerInfo.specification_id#,
"specificationId"=#local.qGetCustomerInfo.specification_id#
}/>
<cfelse>
<cfreturn {}/> <!--- неуклюжий способ обозначить ошибку --->
</cfif>
+1 -2
View File
@@ -47,7 +47,7 @@
left outer join usr u on (e.updater_id=u.usr_id)
where e.instance_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.instanceUid#" null=#!isValid('guid',arguments.instanceUid)#/>
AND s.specification_id=<cfqueryparam cfsqltype="cf_sql_integer" value=#arguments.specificationId#/><!--- access protection --->
</cfquery> <!--- *** правильнее при попытке доступа к чужому инстансу (НСД) выбрасывать 403, а тут будет 404 --->
</cfquery> <!--- *** правильнее при попытке доступа к чужому инстансу (НСД) выбрасывать 403, а тут будет 404, но так тоже делают, например, в gitea --->
<cfif local.qInstance.recordCount EQ 0>
<cfreturn representationOf("Instance not found or no permission to view").withStatus(404)/>
@@ -77,7 +77,6 @@
<!--- <cfdump var=#local.qInstance#/><cfabort/> --->
<!--- операция, создавшая текущее состояние --->
<!--- *** странноватый селект --->
<cfquery name="local.qOperation" result="local.result">
+1 -1
View File
@@ -7,7 +7,7 @@
<cffunction name="get" hint="Шаблон экземпляра"><!--- *** TODO проверка принадлежности тенанту --->
<cfargument name="svcId" type="string" required=true hint="type:integer"/>
<cfargument name="usrId" type="string" required=true hint="type:integer"/><!--- arguments.usrId неявно вбрасывается из Application.cfm --->
<!--- <cfargument name="usrId" type="string" hint="type:integer; no need to provide this argument in request, it is injected by IAM"/> ---><!--- arguments.usrId неявно вбрасывается из Application.cfm --->
<cftry>
<cfset this.helper.validateField(arguments, "svcId", "integer")/>
+1 -1
View File
@@ -8,7 +8,7 @@
<cffunction name="get" hint="Шаблон операции экземпляра"><!--- *** TODO проверка принадлежности тенанту --->
<cfargument name="svcOperationId" type="string" required=true hint="type:integer"/>
<cfargument name="usrId" type="string" required=true hint="type:integer"/><!--- arguments.usrId неявно инжектируется из Application.cfm --->
<!--- <cfargument name="usrId" type="string" hint="type:integer; no need to provide this argument in request, it is injected by IAM"/> ---><!--- arguments.usrId неявно инжектируется из Application.cfm --->
<cftry>
<cfset this.helper.validateField(arguments, "svcOperationId", "integer")/>
+7 -4
View File
@@ -72,8 +72,10 @@
<cfelse>
<cfset local.cfsParamChecker.checkParam(local.qCheckCfsParams.svc_operation_cfs_param_id, qCheckCfsParams.param_value, qCheckCfsParams.instance_operation_cfs_param_uid)/>
</cfif>
</cfloop><!--- <cfdump var=#local.qCheckCfsParams#/><cfabort/> --->
</cfloop><!--- <cfdump var=#local.qCheckCfsParams#/><cfabort/> --->
<!--- ***** тут должен быть контроль доступа на уровне параметров. Желательно по максимуму параноидальный --->
<!--- ***** или при сабмите. Может быть, и на уровне RFS параметров тоже --->
<cfset generateRfsParams(arguments.instanceOperationUid, arguments.usrId)/>
<cfset submitJob(arguments.instanceOperationUid)/>
@@ -86,7 +88,7 @@
</cftry>
<!--- <cfreturn representationOf("Not Implemented yet").withStatus(501)/> --->
<cfset generateRfsParams(arguments.instanceOperationUid)/>
<cfset generateRfsParams(arguments.instanceOperationUid)/><!--- *** а это зачем? прокомментировать --->
<!--- --->
<cfreturn noData().withStatus(201, "Created") />
@@ -96,7 +98,7 @@
<cffunction name="generateRfsParams">
<cfargument name="instanceOperationUid" type="guid"/>
<cfargument name="usrId" type="numeric"/>
<cfargument name="usrId" type="numeric"/><!--- *** инжектируется? --->
<!---
-- полезный селект, не выбрасывать
<cfquery name="qSvcOperationCfsParam">
@@ -256,6 +258,7 @@
</cffunction>
<!--- *** судя по всему, RFS параметр не обязан быть специфицирован на сервисе (никак не проверяется) --->
<cffunction name="setInstanceOperationRfsParam">
<cfargument name="instanceOperationUid" type="guid">
<cfargument name="param"><!--- значение не должно содержать лишних пробелов, чувствительность к регистру определяется БД --->
+5 -2
View File
@@ -65,10 +65,13 @@
from resource_realm r
join resource_realm_type t on (r.resource_realm_type_id=t.resource_realm_type_id)
left outer join resource_realm p on (r.parent_id=p.resource_realm_id)
--join resource_realm_access a on a.
join resource_realm_access a on
(r.resource_realm_id=a.resource_realm_id
AND a.contract_id=<cfqueryparam cfsqltype="CF_SQL_INTEGER" value=#arguments.contractId#/>
AND a.is_enabled)
where 1=1 <m:filter_build filter=#filter#/>
order by <m:order_build sortCollection=#this.helper.parseNumericOrder(local.titleMap, arguments.orderBy)# fieldCount=0/><!---no sort length limit--->
--limit #maxrows#
limit #maxrows#
</cfquery>
<cftry>
+1 -1
View File
@@ -7,7 +7,7 @@
<cffunction name="get" hint="Шаблон экземпляра"><!--- *** TODO проверка принадлежности тенанту --->
<cfargument name="svcId" type="string" required=true hint="type:integer"/>
<cfargument name="usrId" type="string" required=true hint="type:integer"/><!--- arguments.usrId неявно вбрасывается из Application.cfm --->
<!--- <cfargument name="usrId" type="string" /> ---><!--- arguments.usrId неявно инжектируется из Application.cfm --->
<cftry>
<cfset this.helper.validateField(arguments, "svcId", "integer")/>