Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add apollo audit log common solution backend #4985

Merged
merged 54 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
4911b87
7.3
BlackBear2003 Jul 3, 2023
b7b7b61
Merge branch 'apolloconfig:master' into add-audit-logs
BlackBear2003 Jul 3, 2023
687b73b
Merge branch 'apolloconfig:master' into add-audit-logs
BlackBear2003 Jul 26, 2023
d1b4574
plc success except jpa part
BlackBear2003 Aug 3, 2023
57eb3d6
successfully run by EntityScan annotation(not a good way)
BlackBear2003 Aug 8, 2023
83e7021
successfully run by add packages to bean registrar
BlackBear2003 Aug 8, 2023
d291b7d
'app create' audit log and query poc success
BlackBear2003 Aug 9, 2023
bf4105d
App create/update/delete poc success.
BlackBear2003 Aug 15, 2023
4031cc2
add License
BlackBear2003 Aug 15, 2023
85a2403
add License
BlackBear2003 Aug 15, 2023
b556305
try to pass tests
BlackBear2003 Aug 16, 2023
668a34e
try to pass tests
BlackBear2003 Aug 16, 2023
ff6fb0e
fix ${revision} to ${project.version}
BlackBear2003 Aug 17, 2023
ac42630
add no-op implement and no-op autoconfiguration.
BlackBear2003 Sep 1, 2023
154a17b
Merge branch 'apolloconfig:master' into add-audit-logs
BlackBear2003 Sep 1, 2023
7608549
rebase and add license
BlackBear2003 Sep 1, 2023
721cd4f
add audit controller
BlackBear2003 Sep 4, 2023
50a1ee5
- change controller
BlackBear2003 Sep 15, 2023
a6e7b3c
- make ApolloAuditHttpInterceptor uses Api while not tracer
BlackBear2003 Sep 15, 2023
ca7469e
- retry workflows
BlackBear2003 Sep 15, 2023
21b061f
- change for code review
BlackBear2003 Sep 19, 2023
1da08c3
- basically finish front-end part.
BlackBear2003 Sep 24, 2023
7be4d34
- fix for hound
BlackBear2003 Sep 24, 2023
c43217e
- update
BlackBear2003 Sep 24, 2023
bae4aad
- update
BlackBear2003 Sep 24, 2023
39491ef
Merge remote-tracking branch 'origin/add-audit-logs' into add-audit-logs
BlackBear2003 Sep 24, 2023
c345830
- add ApolloAuditLogApiNoOpImpl.class to @ContextConfiguration at App…
BlackBear2003 Sep 25, 2023
87ef435
- add license and fix for hound
BlackBear2003 Sep 25, 2023
4ce1f9d
- fix front-end bug
BlackBear2003 Sep 30, 2023
8a45abf
- fix front-end bug
BlackBear2003 Sep 30, 2023
beecd44
- remove query for auditing AppNamespace
BlackBear2003 Sep 30, 2023
c73c8d7
fix for changed requested
BlackBear2003 Oct 4, 2023
0e4f852
- change: always record if the method have no annotation
BlackBear2003 Oct 8, 2023
2dc02c0
- add test cover manually add dataInfluence when delete app
BlackBear2003 Oct 10, 2023
bbdd361
- try to write part of tests in impl
BlackBear2003 Oct 15, 2023
d0654b3
- finish ApolloAuditLogApiJpaImplTest
BlackBear2003 Oct 16, 2023
f0eaa34
- finish most part of context's unit-tests
BlackBear2003 Oct 16, 2023
ba3c354
- finish some unit-tests
BlackBear2003 Oct 17, 2023
ad324de
- fix database design bug
BlackBear2003 Oct 17, 2023
add5f0d
- add prompt sheet for disabling audit log feature
BlackBear2003 Oct 19, 2023
a154f53
- fix test bugs
BlackBear2003 Oct 19, 2023
62cbdc9
- change the way of getting op-type for data influences
BlackBear2003 Oct 20, 2023
b7a2c25
- enhance front-end design
BlackBear2003 Oct 20, 2023
08f6fb9
- enhance front-end design
BlackBear2003 Oct 20, 2023
a6ff3a6
Merge branch 'master' into add-audit-logs
BlackBear2003 Oct 21, 2023
37a8148
- add AuditLog Search dropdown
BlackBear2003 Oct 21, 2023
ee5c271
- add any-match data influences for batch-delete operation auditing
BlackBear2003 Oct 24, 2023
1e04137
- fix bugs
BlackBear2003 Oct 24, 2023
93b2907
- fix front-end bugs
BlackBear2003 Oct 25, 2023
36f0d75
- fix test failure
BlackBear2003 Oct 25, 2023
37c1458
- fix test failure
BlackBear2003 Oct 25, 2023
5430d0b
- update javadoc
BlackBear2003 Oct 25, 2023
c670758
- update README
BlackBear2003 Oct 25, 2023
f4de3b3
- update README
BlackBear2003 Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apollo-adminservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-biz</artifactId>
</dependency>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-audit-spring-boot-starter</artifactId>
</dependency>
<!-- end of apollo -->
<dependency>
<groupId>org.springframework.cloud</groupId>
Expand Down
4 changes: 4 additions & 0 deletions apollo-adminservice/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@

# You may change the following config to activate different database profiles like h2/postgres
spring.profiles.group.github = mysql

# true: enabled the new feature of audit log
# false/missing: disable it
apollo.audit.log.enabled = true
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.ctrip.framework.apollo.assembly;

import com.ctrip.framework.apollo.adminservice.AdminServiceApplication;
import com.ctrip.framework.apollo.audit.configuration.ApolloAuditAutoConfiguration;
import com.ctrip.framework.apollo.configservice.ConfigServiceApplication;
import com.ctrip.framework.apollo.portal.PortalApplication;

Expand All @@ -31,7 +32,7 @@
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class})
HibernateJpaAutoConfiguration.class, ApolloAuditAutoConfiguration.class})
public class ApolloApplication {

private static final Logger logger = LoggerFactory.getLogger(ApolloApplication.class);
Expand Down
4 changes: 4 additions & 0 deletions apollo-assembly/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@

# You may change the following config to activate different database profiles like h2/postgres
spring.profiles.group.github = mysql

# true: enabled the new feature of audit log
# false/missing: disable it
apollo.audit.log.enabled = true
31 changes: 31 additions & 0 deletions apollo-audit/apollo-audit-annotation/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023 Apollo Authors
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>apollo-audit</artifactId>
<groupId>com.ctrip.framework.apollo</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>apollo-audit-annotation</artifactId>
<version>${revision}</version>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2023 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.audit.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ApolloAuditLog {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need javadoc in all annotation and api

OpType type();
String name() default "";
String description() default "no description";
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2023 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.audit.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface ApolloAuditLogDataInfluence {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2023 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.audit.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.TYPE, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface ApolloAuditLogDataInfluenceTable {

String tableName();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2023 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.audit.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface ApolloAuditLogDataInfluenceTableField {

String fieldName();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2023 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.audit.annotation;

public enum OpType {
CREATE, UPDATE, DELETE, RPC
}
38 changes: 38 additions & 0 deletions apollo-audit/apollo-audit-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023 Apollo Authors
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>apollo-audit</artifactId>
<groupId>com.ctrip.framework.apollo</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>apollo-audit-api</artifactId>
<version>${revision}</version>

<dependencies>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-audit-annotation</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2023 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.audit.api;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class ApolloAuditEntityDefinition {

private String entityName;

private List<Field> dataInfluenceFields;

private Field entityIdField;

public ApolloAuditEntityDefinition() {
this.dataInfluenceFields = new ArrayList<>();
}

public ApolloAuditEntityDefinition entityName(String val) {
this.entityName = val;
return this;
}

public ApolloAuditEntityDefinition entityIdField(Field f) {
this.entityIdField = f;
return this;
}

public ApolloAuditEntityDefinition dataInfluenceFields(List<Field> val) {
this.dataInfluenceFields = val;
return this;
}

public ApolloAuditEntityDefinition addDataInfluenceFields(Field f) {
this.dataInfluenceFields.add(f);
return this;
}

public String getEntityName() {
return entityName;
}

public Field getEntityIdField() {
return entityIdField;
}

public List<Field> getDataInfluenceFields() {
return dataInfluenceFields;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2023 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.audit.api;

public interface ApolloAuditLogApi extends ApolloAuditLogRecordApi, ApolloAuditLogQueryApi{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2023 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.audit.api;

import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDTO;
import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDataInfluenceDTO;
import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDetailsDTO;
import java.util.Date;
import java.util.List;

public interface ApolloAuditLogQueryApi {

List<ApolloAuditLogDTO> queryLogs(int page, int size);

List<ApolloAuditLogDTO> queryLogsByOpName(String opName, Date startDate, Date endDate, int page,
int size);

List<ApolloAuditLogDetailsDTO> queryTraceDetails(String traceId);

List<ApolloAuditLogDataInfluenceDTO> queryDataInfluencesByField(String entityName,
String entityId, String fieldName, int page, int size);

List<ApolloAuditLogDTO> searchLogByNameOrTypeOrOperator(String query, int page, int size);

}
Loading
Loading