Send audit records to Syslog
This guide explains how to send the audit records of Casdoor to a Syslog server, for example the collector of a security information and event management (SIEM) system. An Audit provider of the type Syslog forwards each record that Casdoor stores, the same records that Auditing > Records lists.
Learning outcomes
- Add a Syslog audit provider.
- Know which records Casdoor sends and in which format.
What you need
- A Syslog server that Casdoor can reach over UDP, TCP, or TLS
- Administrator access to the Casdoor admin console
Add the provider
-
In the Casdoor admin console, go to Identity > Providers and add a provider.
-
Set Category to
Audit. Casdoor sets Type toSyslog, the only type, and fills in the defaults. -
Fill in the fields:
Field Description Host Host name or IP address of the Syslog server. Required Port Port of the Syslog server, from 1 to 65535. The default is 514. When you switch Protocol toTLS, Casdoor changes514to6514, and back when you switch away fromTLSProtocol UDP(default),TCP, orTLSFacility Syslog facility of the messages: auth(default),authpriv,user,daemon,security, orlocal0tolocal7Format RFC 5424(default) orRFC 3164State Enabled(default) orDisabled. Casdoor sends nothing through a disabled provider -
Save the provider. Casdoor rejects invalid settings, such as an empty host, when you save.
You don't add an Audit provider to an application. It takes effect as soon as you save it.
Which records Casdoor sends
Casdoor sends each record to the enabled Audit providers of the global admin organization and to those of the organization of the record. A record without an organization belongs to built-in.
The records are the ones that Casdoor stores in its audit log. With logPostOnly set to true in conf/app.conf, the default, Casdoor doesn't record GET requests, except for logout and sso-logout. See the Configuration reference.
Message format
The message is the record as JSON, on a single line. Casdoor masks secrets in the request body, such as passwords, and replaces line breaks with spaces.
The severity is 4 (warning) if the status code of the request is 400 or higher, or the response is an error. Otherwise, it is 6 (informational). The priority is the facility number multiplied by 8, plus the severity.
RFC 5424:
<priority>1 <time> <hostname> casdoor <process-id> <action> - <record-json>
RFC 3164:
<priority><time> <hostname> casdoor[<process-id>]: <record-json>
<time>is the time of the record, in the RFC 3339 format forRFC 5424, and in the formatJan _2 15:04:05forRFC 3164.<hostname>is the host name of the Casdoor server.<action>is the action of the record, such asloginorupdate-user, with at most 32 characters.
Delivery
- Casdoor sends the messages in the background, from a queue of 10,000 messages per provider. If the queue is full, Casdoor drops the new record and logs an error.
- If the connection fails, Casdoor retries the message every 10 seconds. Connecting and writing each time out after 5 seconds.
- Over UDP, each datagram carries one message, cut to 60,000 bytes. Over TCP and TLS, each message ends with a line feed.
- Over TLS, Casdoor requires TLS 1.2 or later, and checks the certificate of the server against Host.
Verify the result
- Save a change in the Casdoor admin console, for example in an application.
- Check the log of the Syslog server. A message from
casdoorwith the action of the change is there.