021 dimensions dimension1

This commit is contained in:
2026-07-20 11:06:58 +03:00
parent 90aa268918
commit 3bc7cea1d1
16 changed files with 2121 additions and 185 deletions
+80 -13
View File
@@ -8,6 +8,7 @@
<!--- Set up the application. --->
<cfset this.Name = "PAYG-REPORT" />
<cfset this.applicationTimeout = createTimeSpan( 0, 3, 0, 0 ) />
<cfset this.applicationTimeout = createTimeSpan( 0, 0, 0, 10 ) />
<cfset this.sessionmanagement="Yes"/>
<cfset this.clientmanagement="No"/>
<cfset this.sessiontimeout=CreateTimeSpan(0, 1, 0, 0)/>
@@ -24,7 +25,8 @@
<cfset this.access_token_endpoint = "https://keycloak.nubes.ru/realms/cloud/protocol/openid-connect/token" />
<cfset this.idpCertUrl = "https://keycloak.nubes.ru/realms/cloud/protocol/openid-connect/certs" />
<cfset this.client_secret = createObject("java", "java.lang.System").getEnv("IDP_CLIENT_SECRET")/>
<cfset this.iam_url = "https://auth-api.ngcloud.ru/api/v1/auth/user"/>
<!--- <cfset this.iam_url = "https://auth-api.ngcloud.ru/api/v1/auth/user"/> --->
<cfset this.iamServiceUrl = "https://auth-api-dev.ngcloud.ru/api/v1/auth/user "/>
<cfset this.redirect_uri = "https://#CGI.SERVER_NAME##CGI.SCRIPT_NAME#"/><!--- куда возвращаться от IDP --->
<cfset this.datasource = "rpt"/><!--- к буферной базе --->
@@ -38,19 +40,30 @@
<!--- *** проверить, что есть - если есть, не создавать --->
<cffunction
<cffunction
name="OnApplicationStart"
access="public"
returntype="boolean"
output="false"
output="false"
hint="Fires when the application is first created.">
<!--- *** мы не проверяем срок жизни сертификата и его отзыв--->
<!--- Obtain idp certificate OnApplicationStart --->
<cfset application.idpCertificate = getIdpCertificate(this.idpCertUrl)/>
<!--- <cfset this.iamServiceUrl = locateIamService()/> --->
<!--- <cfreturn super.onApplicationStart() /> --->
<cfreturn true />
</cffunction>
<cffunction name="onRequestStart" returnType="boolean">
<cfargument name="targetPage" type="string" required="true" />
<cfif structKeyExists(url, "application_reset")>
<cfset ApplicationStop() />
<cflocation url="index.cfm" addtoken="false" />
</cfif>
<cfreturn true />
</cffunction>
<cffunction
@@ -77,7 +90,7 @@
<!--- global settings --->
<cfset request.RECORDS_PER_PAGE=500/>
<cfset request.APP_VERSION="0.00.020"/>
<cfset request.APP_VERSION="0.00.021"/>
<cfheader name="X-Application-Version" value=#request.APP_VERSION#/>
<cfset request.STAND=getStand()/>
@@ -176,16 +189,30 @@
Кладем данные из токена в реквест и наслаждаемся --->
<!--- Вариант: если есть Authorization:bearer, идем с ним к IAM --->
<cfscript>
<cfscript>
var requestData = GetHttpRequestData();
var headers = requestData.headers;
//var authorizationHeader = server.system.environment?.AUTHORIZATION;
if (structKeyExists(headers,"Authorization")) {
request.auth_header = headers.Authorization;
} else {
//request.auth_header = createObject("java", "java.lang.System").getEnv("AUTHORIZATION");
request.auth_header = server.system.environment?.AUTHORIZATION; //так короче
if (isNull(request.auth_header)){ /*for local debug we can inject long-living token into environment*/
structDelete(request,"auth_header");
} else {
request.auth_header = "Bearer #request.auth_header#";
}
}
if (structKeyExists(headers,"authorization")) { // аутентификация для клиента ЛК
var authorizationHeader = headers.authorization;
// if (structKeyExists(headers,"authorization")) { // аутентификация для клиента ЛК
if (structKeyExists(request,"auth_header")) { // аутентификация для клиента ЛК
var authorizationHeader = request.auth_header;
if (authorizationHeader.startsWith("Bearer ")) {
var bearerToken = Mid(authorizationHeader, 8);
writeDump(bearerToken);
//writeDump(bearerToken);
//var token=toString(binaryDecode(bearerToken, "base64"));
//writeDump(token);
//jwt = new lib.jwt(this.client_secret);
@@ -194,7 +221,7 @@
//}
var result="";
//try {
var iamService = new http(method = "GET", charset = "utf-8", url = #this.iam_url#, timeout="5");
var iamService = new http(method = "GET", charset = "utf-8", url = #this.iamServiceUrl#, timeout="5");
iamService.addParam(type = "HEADER", name = "Accept", value = "application/json");
iamService.addParam(type = "HEADER", name = "Authorization", value = "#authorizationHeader#"); //passthrough
//writedump(this.iamServiceUrl);abort;
@@ -206,7 +233,7 @@
//writedump(this.iamServiceUrl);
//writedump(resp);
var iamStatusCode = (isValid("integer", prefix.status_code)) ? val(prefix.status_code) : 500;
throw(message="IAM error", detail="URL: #this.iam_url# Status Code: #prefix.status_code#");
throw(message="IAM error", detail="URL: #this.iamServiceUrl# Status Code: #prefix.status_code#");
//abort;
//throw("IDP response not OK");
}
@@ -314,6 +341,10 @@
}
request.auth.wz='WZ01348'; //*******************
request.auth.wz='WZ01005'; //*******************
request.auth.wz='WZ01653'; //*******************
request.auth.wz='WZ02319'; //*******************
request.auth.wz='WZ01762'; //*******************
</cfscript>
@@ -519,4 +550,40 @@
</cftry>
<cfthrow type="Context validation error" message="RETHROW() called outside TRY-CATCH"/>
</cffunction>
<!--- как определить стенд? Из персистенса. Из окружения --->
<!--- <cffunction name="locateIamService"><!--- *** архитектурный колхоз --->
<!--- почему-то мы не видим других функций, когда нас вызывают onApplicationStart. С другой стороны, а почему вообще должны вызывать без перезагрузки приложения --->
<cfset var stand=""/>
<!--- дублируем код, потому что getStand отсюда почему-то не виден --->
<cftry>
<cfquery name=qConfig>
select value as stand from config
where name='STAND'
</cfquery>
<cfset stand = qConfig.stand/>
<cfswitch expression=#stand#>
<cfcase value=",dev">
<cfreturn "https://auth-api-dev.ngcloud.ru/api/v1" />
</cfcase>
<cfcase value="test">
<cfreturn "https://auth-api-test.ngcloud.ru/api/v1" />
</cfcase>
<cfcase value="prod">
<cfreturn "https://auth-api.ngcloud.ru/api/v1" />
</cfcase>
<cfdefaultcase><!--- proceed to the legacy locator ---></cfdefaultcase>
</cfswitch>
<cfcatch type="ANY">
<!--- do nothing, proceed to the legacy locator --->
<cfrethrow/>
<cfthrow message="IAM service unavailable" detail="there is no IAM for stand #stand# defined"/>
</cfcatch>
</cftry>
</cffunction> --->
</cfcomponent>