https://github.com/melthaw/spring-mvc-audit
The simple rest audit extension base on Spring MVC framework.
https://github.com/melthaw/spring-mvc-audit
audit java spring
Last synced: about 2 months ago
JSON representation
The simple rest audit extension base on Spring MVC framework.
- Host: GitHub
- URL: https://github.com/melthaw/spring-mvc-audit
- Owner: melthaw
- License: apache-2.0
- Created: 2017-07-21T08:08:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-19T12:58:15.000Z (over 8 years ago)
- Last Synced: 2025-01-10T14:29:00.091Z (over 1 year ago)
- Topics: audit, java, spring
- Language: Java
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
The simple and quick audit lib for spring mvc http request.
The audit log will be sent by:
* [Edm](https://github.com/melthaw/spring-event-driven-message)
* Kafka
# Dependencies
* Spring Mvc Framework (Over 3)
* in.clouthink:daas-edm:1.* (optional)
* org.springframework.kafka:spring-kafka:2.* (optional)
* io.swagger:swagger-annotations:1.5.x
# Usage
So far the following version is available
module name | latest version
------|------
daas-audit | 1.1.0
## Maven
in.clouthink.daas
daas-audit
${daas.audit.version}
## Gradle
compile "in.clouthink.daas:daas-audit:${daas_audit_version}"
## Spring Configuration
Use `@EnableAudit` to get started
@Configuration
@EnableAudit
public class Application {}
The principal who triggers audit event is very important, but we don't know which security framework is chosen by end user.
To make it run , the end user has to supply the minimized implementation as follow
public class SecurityContextImpl implements SecurityContext {
@Override
public String getPrincipal() {
//TODO
}
}
And add service file which named `in.clouthink.daas.audit.security.SecurityContext` to META-INF/services.
The content of the service file should be the full quantifier path of the implementation.
## How to customize
We supply the following extension points to make the customization easy and happy.
* in.clouthink.daas.audit.spi.AuditEventResolver
* in.clouthink.daas.audit.spi.AuditEventPersister
The default implementations list as follow:
* in.clouthink.daas.audit.spi.impl.DefaultAuditEventResolver
* in.clouthink.daas.audit.spi.impl.DefaultAuditEventPersister
The end user can supply their own implementations and override the default value by `AuditConfigurer`.
@Bean
public AuditConfigurer auditConfigurer() {
return new AuditConfigurer() {
@Override
public void configure(AuditExecutionConfigurer auditExecutionConfigurer) {
//do configure
}
};
}
Here is the definition of `AuditExecutionConfigurer` , four ways to customize the audit features.
public interface AuditExecutionConfigurer {
/**
* RequestMapping is taking by default
*
* @param auditAnnotationType
*/
void setAuditAnnotationType(Class extends Annotation> auditAnnotationType);
/**
* DefaultAuditEventResolver is taking by default
*
* @param auditEventResolver
*/
void setAuditEventResolver(AuditEventResolver auditEventResolver);
/**
* DefaultAuditEventPersister is taking by default
*
* @param auditEventPersister
*/
void setAuditEventPersister(AuditEventPersister auditEventPersister);
/**
* @param errorDetailRequired true : the full stack of the error
* false (default) : only the error message
*/
void setErrorDetailRequired(boolean errorDetailRequired);
}