Audit events in TRUE Connector

February 19, 2024 ยท View on GitHub

Audit events are stored in database (H2 with default configuration, possible to replace with PostgreSQL), this way tampering of the logs is prohibited. Entries in database are done only by the Execution Core Container. Column for storing auditLog entry is encrypted using AES/GCM/NoPadding algorithm which requires user to set valid password. It must be done using environment variable with following name: AES256-SECRET-KEY.
When ECC inserts audit entry into Database, AuditLog value will be encrypted using provided algorithm, and when data is requested, it will be decrypted.
ECC exposes protected endpoint, for API user, to fetch all audit logs, or audit logs for specific date:

https://localhost:8090/api/audit/

or for specific date

https://localhost:8090/api/audit/?date=2024-02-12

NOTE: date format must be in YYYY-MM-DD format. Otherwise response will be https 400 - bad request.

Audit event types

TRUE Connector has list of audit events which can be found in following table:

TRUE Connector audit event typeDescription
TRUE_CONNECTOR_EVENTDefault TRUE Connector event
HTTP_REQUEST_RECEIVEDHttp request received
USER_AUTHORIZATION_FAILUREAuthorization failure
USER_AUTHORIZATION_SUCCESSAuthorization success
USER_AUTHENTICATION_FAILUREAuthentication failure
USER_AUTHENTICATION_SUCCESSAuthentication success
USER_BLOCKEDUser blocked
SELF_DESCRIPTIONSelf description requested
CONTRACT_OFFERContract offer requested
CONTRACT_OFFER_CREATEDContract offer created
CONTRACT_OFFER_CREATION_FAILEDContract offer creation failed
CONTRACT_OFFER_UPDATEDContract offer updated
CONTRACT_OFFER_UPDATE_FAILEDContract offer update failed
CONTRACT_OFFER_DELETEDContract offer deleted
OFFERED_RESOURCEOffered resource requested
OFFERED_RESOURCE_CREATEDOffered resource created
OFFERED_RESOURCE_CREATION_FAILEDOffered resource creation failed
OFFERED_RESOURCE_UPDATEDOffered resource updated
OFFERED_RESOURCE_UPDATE_FAILEDOffered resource update failed
OFFERED_RESOURCE_DELETEDOffered resource deleted
REPRESENTATIONRepresentation requested
REPRESENTATION_CREATEDRepresentation created
REPRESENTATION_CREATION_FAILEDRepresentation creation failed
REPRESENTATION_UPDATEDRepresentation updated
REPRESENTATION_UPDATE_FAILEDRepresentation update failed
REPRESENTATION_DELETEDRepresentation deleted
EXCEPTION_BAD_REQUESTBad request
EXCEPTION_NOT_FOUNDEntity not found
EXCEPTION_SERVER_ERRORServer error
EXCEPTION_GENERALGeneral exception
CONNECTORConnector event
CONNECTOR_REQUESTConnector received message
CONNECTOR_RESPONSEConnector received response
CONNECTOR_SENDConnector message forwarding
CONNECTOR_SEND_DATAAPPConnector message forwarding - dataApp
CONNECTOR_TOKEN_FETCH_SUCCESSConnector obtained DAT token
CONNECTOR_TOKEN_FETCH_FAILUREConnector could not obtain DAT token
CONNECTOR_VALIDATED_TOKEN_SUCCESSConnector validated DAT token successfully
CONNECTOR_VALIDATED_TOKEN_FAILConnector failed to validate DAT token
CONNECTOR_CLEARING_HOUSE_SUCCESSConnector registered transaction to clearing house
CONNECTOR_CLEARING_HOUSE_FAILUREConnector could not register transaction to clearing house
CONNECTOR_CONTRACT_AGREEMENT_SUCCESSConnector contract agreement upload success
CONNECTOR_CONTRACT_AGREEMENT_FAILEDConnector contract agreement upload failed
CONNECTOR_POLICY_ENFORCEMENT_SUCCESSConnector successfully enforces policy
CONNECTOR_POLICY_ENFORCEMENT_FAILEDConnector failed to enforce policy
CONNECTOR_BROKER_REGISTERConnector register connector to Broker
CONNECTOR_BROKER_UPDATEConnector update Broker registration
CONNECTOR_BROKER_PASSIVATEConnector passivate connector on Broker
CONNECTOR_BROKER_DELETEConnector delete connector from Broker
CONNECTOR_BROKER_QUERYConnector query to Broker
CONNECTOR_INTERNAL_HEALTHYConnector internal state is healthy
CONNECTOR_INTERNAL_UNHEALTHYConnector internal state is unhealthy
CONNECTOR_EXTERNAL_HEALTHYConnector external state is healthy
CONNECTOR_EXTERNAL_UNHEALTHYConnector external state is unhealthy

Audit event configuration

User can configure TRUE Connector to include or exclude some events to be logged or not. This can be done with following property in application.property file:

auditableEvents=ALL,NONE,SELF_DESCRIPTION,SELF_DESCRIPTION_ALL,CONTRACT_OFFER,OFFERED_RESOURCE,REPRESENTATION,USER,EXCEPTION,CONNECTOR

User has possibility to turn on all audit events, by setting property to ALL, or to turn off all events by setting the property to NONE, or make combination to turn on only specific events, by setting up correct property.

Here is the binding of properties and which events are covered with it:

Audit propertyTRUE Connector audit event typeNote
SELF_DESCRIPTIONSELF_DESCRIPTIONEvent when connector's Self description is requested
SELF_DESCRIPTION_ALLSELF_DESCRIPTION, CONTRACT_OFFER, OFFERED_RESOURCE, OFFERED_RESOURCE, REPRESENTATIONAll events related with Self Description activities, include events wrapped up with properties from the list
CONTRACT_OFFERCONTRACT_OFFER, CONTRACT_OFFER_CREATED, CONTRACT_OFFER_CREATION_FAILED, CONTRACT_OFFER_UPDATED, CONTRACT_OFFER_UPDATE_FAILED, CONTRACT_OFFER_DELETEDEvents related with Contract offer manipulation (requested, created, updated, deleted)
OFFERED_RESOURCEOFFERED_RESOURCE, OFFERED_RESOURCE_CREATED, OFFERED_RESOURCE_CREATION_FAILED, OFFERED_RESOURCE_UPDATED, OFFERED_RESOURCE_UPDATE_FAILED, OFFERED_RESOURCE_DELETEDEvents related with Offered resource manipulation (requested, created, updated, deleted)
REPRESENTATIONREPRESENTATION, REPRESENTATION_CREATED, REPRESENTATION_CREATION_FAILED, REPRESENTATION_UPDATED, REPRESENTATION_UPDATE_FAILED, REPRESENTATION_DELETEDEvents related with Representation manipulation (requested, created, updated, deleted)
CONNECTORCONNECTOR_REQUEST, CONNECTOR_RESPONSE, CONNECTOR_SEND, CONNECTOR_SEND_DATAAPP, CONNECTOR_TOKEN_FETCH_SUCCESS,CONNECTOR_TOKEN_FETCH_FAILURE , CONNECTOR_VALIDATED_TOKEN_SUCCESS, CONNECTOR_TOKEN_VALIDATED_FAILURE, CONNECTOR_CLEARING_HOUSE_SUCCESS,CONNECTOR_CLEARING_HOUSE_FAILURE , CONNECTOR_CONTRACT_AGREEMENT_SUCCESS, CONNECTOR_CONTRACT_AGREEMENT_FAILED, CONNECTOR_POLICY_ENFORCEMENT_SUCCESS, CONNECTOR_POLICY_ENFORCEMENT_FAILED, CONNECTOR_BROKER_REGISTER, CONNECTOR_BROKER_UPDATE, CONNECTOR_BROKER_PASSIVATE, CONNECTOR_BROKER_DELETE, CONNECTOR_BROKER_QUERY, CONNECTOR_INTERNAL_HEALTHY, CONNECTOR_INTERNAL_UNHEALTHY, CONNECTOR_EXTERNAL_HEALTHY, CONNECTOR_EXTERNAL_UNHEALTHYEvents related with message exchange process
USERUSER_AUTHORIZATION_FAILURE, USER_AUTHORIZATION_SUCCESS, USER_BLOCKEDUser activity related events
EXCEPTIONEXCEPTION_BAD_REQUEST, EXCEPTION_NOT_FOUND, EXCEPTION_SERVER_ERROR, EXCEPTION_GENERALAll events that are translated to invalid state (errors)

Example of Audit log entry

With default configuration, events will be logged in log file, in JSON format, like following:

[
    {
        "id": 1,
        "timestamp": "2024-02-12T11:02:34.567174",
        "event": "UsernamePasswordAuthenticationToken [Principal=User{id='7d330566-3c3b-4358-99aa-77fd09e6fec7', username='apiUser', password='[PROTECTED]', role='API_USER', accountNonExpired=true, accountNonLocked=true, credentialsNonExpired=true, enabled=true}, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=null], Granted Authorities=[ROLE_API_USER]]"
    },
    {
        "id": 2,
        "timestamp": "2024-02-12T11:03:33.26411",
        "event": "UsernamePasswordAuthenticationToken [Principal=User{id='7d330566-3c3b-4358-99aa-77fd09e6fec7', username='apiUser', password='[PROTECTED]', role='API_USER', accountNonExpired=true, accountNonLocked=true, credentialsNonExpired=true, enabled=true}, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=null], Granted Authorities=[ROLE_API_USER]]"
    },
    {
        "id": 3,
        "timestamp": "2024-02-12T11:04:47.443094",
        "event": "UsernamePasswordAuthenticationToken [Principal=User{id='7d330566-3c3b-4358-99aa-77fd09e6fec7', username='apiUser', password='[PROTECTED]', role='API_USER', accountNonExpired=true, accountNonLocked=true, credentialsNonExpired=true, enabled=true}, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=null], Granted Authorities=[ROLE_API_USER]]"
    },
        {
        "id": 4,
        "timestamp": "2024-02-12T11:54:09.858569",
        "event": "AuditEvent [timestamp=2024-02-12T10:54:09.857568300Z, principal=idsUser, type=CONNECTOR_REQUEST, data={http.message=de.fraunhofer.iais.eis.ArtifactRequestMessageImpl, correlationId=ba5228e6-648c-44ad-aa85-a1ce0d8af809, http.method=POST}]"
    },
    {
        "id": 5,
        "timestamp": "2024-02-12T11:54:09.896071",
        "event": "AuditEvent [timestamp=2024-02-12T10:54:09.895003300Z, principal=idsUser, type=CONNECTOR_SEND, data={http.message=de.fraunhofer.iais.eis.ArtifactRequestMessageImpl, correlationId=ba5228e6-648c-44ad-aa85-a1ce0d8af809, http.method=POST}]"
    },
    {
        "id": 90,
        "timestamp": "2024-02-12T11:59:51.69915",
        "event": "AuditEvent [timestamp=2024-02-12T10:59:51.698151Z, principal=apiUser, type=HTTP_REQUEST_RECEIVED, data={http.headers={authorization=******, content-length=2968, resource=https://w3id.org/idsa/autogen/textResource/67ce1330-41fb-421a-8166-268746be5f17, host=localhost:8443, content-type=application/json, connection=keep-alive, accept-encoding=gzip, deflate, br, user-agent=PostmanRuntime/7.36.1, accept=*/*}, payload={\r\n    \"@context\": {\r\n        \"ids\": \"https://w3id.org/idsa/core/\",\r\n        \"idsc\": \"https://w3id.org/idsa/code/\"\r\n    },\r\n    \"@type\": \"ids:ContractOffer\",\r\n    \"@id\": \"https://w3id.org/idsa/autogen/contractOffer/a6cc0285-c948-48f2-9fa9-59bad3dbd825\",\r\n    \"ids:permission\": [\r\n        {\r\n            \"@type\": \"ids:Permission\",\r\n            \"@id\": \"https://w3id.org/idsa/autogen/permission/48047208-39df-4efe-881b-a2c444cf139a\",\r\n            \"ids:target\": {\r\n                \"@id\": \"http://w3id.org/engrd/connector/artifact/test\"\r\n            },\r\n            \"ids:description\": [\r\n                {\r\n                    \"@value\": \"provide-access\",\r\n                    \"@type\": \"http://www.w3.org/2001/XMLSchema#string\"\r\n                }\r\n            ],\r\n            \"ids:action\": [\r\n                {\r\n                    \"@id\": \"https://w3id.org/idsa/code/USE\"\r\n                }\r\n            ],\r\n            \"ids:title\": [\r\n                {\r\n                    \"@value\": \"Example Usage Policy\",\r\n                    \"@type\": \"http://www.w3.org/2001/XMLSchema#string\"\r\n                }\r\n            ],\r\n            \"ids:preDuty\": [],\r\n            \"ids:constraint\": [\r\n                {\r\n                    \"@type\": \"ids:Constraint\",\r\n                    \"@id\": \"https://w3id.org/idsa/autogen/constraint/f2cdadc7-3ac9-4eda-a7cf-c60822d53311\",\r\n                    \"ids:rightOperand\": {\r\n                        \"@value\": \"2024-02-12T10:59:51.570Z\",\r\n                        \"@type\": \"http://www.w3.org/2001/XMLSchema#dateTimeStamp\"\r\n                    },\r\n                    \"ids:leftOperand\": {\r\n                        \"@id\": \"https://w3id.org/idsa/code/POLICY_EVALUATION_TIME\"\r\n                    },\r\n                    \"ids:operator\": {\r\n                        \"@id\": \"https://w3id.org/idsa/code/AFTER\"\r\n                    }\r\n                },\r\n                {\r\n                    \"@type\": \"ids:Constraint\",\r\n                    \"@id\": \"https://w3id.org/idsa/autogen/constraint/79309e91-54eb-4325-aff7-3909d71626b3\",\r\n                    \"ids:rightOperand\": {\r\n                        \"@value\": \"2024-04-12T09:59:51.557Z\",\r\n                        \"@type\": \"http://www.w3.org/2001/XMLSchema#dateTimeStamp\"\r\n                    },\r\n                    \"ids:leftOperand\": {\r\n                        \"@id\": \"https://w3id.org/idsa/code/POLICY_EVALUATION_TIME\"\r\n                    },\r\n                    \"ids:operator\": {\r\n                        \"@id\": \"https://w3id.org/idsa/code/BEFORE\"\r\n                    }\r\n                }\r\n            ]\r\n        }\r\n    ],\r\n    \"ids:provider\": {\r\n        \"@id\": \"https://w3id.org/engrd/connector/\"\r\n    },\r\n    \"ids:contractStart\": {\r\n        \"@value\": \"2024-02-12T10:59:51.570Z\",\r\n        \"@type\": \"http://www.w3.org/2001/XMLSchema#dateTimeStamp\"\r\n    },\r\n    \"ids:contractDate\": {\r\n        \"@value\": \"2024-02-12T10:59:51.570Z\",\r\n        \"@type\": \"http://www.w3.org/2001/XMLSchema#dateTimeStamp\"\r\n    }\r\n}, http.path=https://localhost:8443/api/contractOffer/, correlationId=4cea31f9-e444-43f4-abc9-cb113a122b23, http.method=POST}]"
    },
    {
        "id": 91,
        "timestamp": "2024-02-12T11:59:51.753177",
        "event": "AuditEvent [timestamp=2024-02-12T10:59:51.751176500Z, principal=apiUser, type=CONTRACT_OFFER_CREATED, data={http.headers={authorization=******, content-length=2968, resource=https://w3id.org/idsa/autogen/textResource/67ce1330-41fb-421a-8166-268746be5f17, host=localhost:8443, content-type=application/json, connection=keep-alive, accept-encoding=gzip, deflate, br, user-agent=PostmanRuntime/7.36.1, accept=*/*}, http.path=https://localhost:8443/api/contractOffer/, correlationId=4cea31f9-e444-43f4-abc9-cb113a122b23, http.method=POST}]"
    }