Fix account legacy and make ServiceClass parametric

This commit is contained in:
Antonio Calanducci 2024-05-31 10:12:38 +02:00
parent a33bce76e3
commit e53a1d594f
2 changed files with 10 additions and 9 deletions

View File

@ -1,13 +1,14 @@
export default { config };
var config = {
"pep_credentials" : "pep_credentials",
"pep_credentials": "pep_credentials",
"debug": true,
"legacy": true,
"accounting": {
"scopes": ["authorized_scope1", "authorizeed_scope2"],
"scopes": ["authorized_scope1", "authorizeed_scope2"],
"service_name": "docker_stack_name",
"host": "service_hostname"
"service_class": "Application",
"host": "service_hostname"
},
"hosts": [
{

View File

@ -46,7 +46,7 @@ function enforce_legacy(r) {
var allowedcontexts = context.config["accounting"]["scopes"]
debug(context, "Allowed Contexts: " + JSON.stringify(allowedcontexts));
debug(context, "PEP config:\n" + JSON.stringify(defaultExport["config"], null, 2))
// debug(context, "PEP config:\n" + JSON.stringify(defaultExport["config"], null, 2))
const token = getGCubeToken(context)
if (token != null) {
@ -509,15 +509,15 @@ function buildAccountingRecord_legacy(context) {
"recordType": "ServiceUsageRecord",
"operationCount": 1,
"creationTime": t,
"callerHost": context.request.remoteAddress,
"serviceClass": "ShinyApp",
"callerHost": context.request.headersIn["x-forwarded-for"],
"serviceClass": context.config["accounting"]["service_class"],
"callerQualifier": "TOKEN",
"consumerId": context.userinfo.username,
"consumerId": context.userinfo.result.username,
"aggregated": true,
"serviceName": context.request.uri.split("app/")[1],
"serviceName": context.config["accounting"]["service_name"],
"duration": 0,
"maxInvocationTime": 0,
"scope": context.userinfo.context,
"scope": context.userinfo.result.context,
"host": context.request.headersIn.host,
"startTime": t,
"id": uuid(),