Skip to content

Commit 0f923cc

Browse files
committed
add SkipAuthorizationFilter
1 parent 1f95d9b commit 0f923cc

20 files changed

Lines changed: 220 additions & 123 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<groupId>com.codingapi.springboot</groupId>
1717
<artifactId>springboot-parent</artifactId>
18-
<version>2.10.35</version>
18+
<version>2.10.36</version>
1919

2020
<url>https://github.com/codingapi/springboot-framewrok</url>
2121
<name>springboot-parent</name>

springboot-starter-data-authorization/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.10.35</version>
9+
<version>2.10.36</version>
1010
</parent>
1111

1212
<name>springboot-starter-data-authorization</name>

springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/DataAuthorizationContext.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package com.codingapi.springboot.authorization;
22

33
import com.codingapi.springboot.authorization.filter.DataAuthorizationFilter;
4+
import com.codingapi.springboot.authorization.filter.DefaultSkipAuthorizationFilter;
5+
import com.codingapi.springboot.authorization.filter.SkipAuthorizationFilter;
46
import com.codingapi.springboot.authorization.handler.Condition;
5-
import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
7+
import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
68
import lombok.Getter;
9+
import lombok.Setter;
710
import org.springframework.util.StringUtils;
811

912
import java.util.ArrayList;
@@ -19,10 +22,22 @@ public class DataAuthorizationContext {
1922

2023
private final List<DataAuthorizationFilter> filters;
2124

25+
@Setter
26+
private SkipAuthorizationFilter skipAuthorizationFilter;
27+
2228
private DataAuthorizationContext() {
2329
this.filters = new ArrayList<>();
30+
this.skipAuthorizationFilter = new DefaultSkipAuthorizationFilter();
31+
}
32+
33+
/**
34+
* 跳过拦截的处理机制
35+
*/
36+
public String skipSQLFilter(String sql){
37+
return this.skipAuthorizationFilter.filter(sql);
2438
}
2539

40+
2641
/**
2742
* 添加数据权限过滤器
2843
* @param filter 数据权限过滤器
@@ -47,7 +62,7 @@ public void clearDataAuthorizationFilters() {
4762
* @return T
4863
* @param <T> 泛型
4964
*/
50-
public <T> T columnAuthorization(SQLInterceptState interceptState, String tableName, String columnName, T value) {
65+
public <T> T columnAuthorization(SQLExecuteState interceptState, String tableName, String columnName, T value) {
5166
if (interceptState != null && interceptState.hasIntercept()) {
5267
String realTableName = interceptState.getTableName(tableName);
5368
String realColumnName = interceptState.getColumnName(tableName,columnName);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.codingapi.springboot.authorization.filter;
2+
3+
public class DefaultSkipAuthorizationFilter implements SkipAuthorizationFilter{
4+
5+
@Override
6+
public String filter(String sql) {
7+
return sql;
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.codingapi.springboot.authorization.filter;
2+
3+
4+
/**
5+
* 跳过数据权限拦截处理机制
6+
*/
7+
public interface SkipAuthorizationFilter {
8+
9+
String filter(String sql);
10+
11+
}
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.codingapi.springboot.authorization.handler;
22

3-
import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
3+
import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
44

55
import java.io.InputStream;
66
import java.io.Reader;
@@ -13,62 +13,62 @@
1313
*/
1414
public interface ColumnHandler {
1515

16-
String getString(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, String value);
16+
String getString(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, String value);
1717

18-
boolean getBoolean(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, boolean value);
18+
boolean getBoolean(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, boolean value);
1919

20-
byte getByte(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, byte value);
20+
byte getByte(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, byte value);
2121

22-
short getShort(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, short value);
22+
short getShort(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, short value);
2323

24-
int getInt(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, int value);
24+
int getInt(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, int value);
2525

26-
long getLong(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, long value);
26+
long getLong(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, long value);
2727

28-
float getFloat(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, float value);
28+
float getFloat(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, float value);
2929

30-
double getDouble(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, double value);
30+
double getDouble(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, double value);
3131

32-
BigDecimal getBigDecimal(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, BigDecimal value);
32+
BigDecimal getBigDecimal(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, BigDecimal value);
3333

34-
byte[] getBytes(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, byte[] value);
34+
byte[] getBytes(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, byte[] value);
3535

36-
Date getDate(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Date value);
36+
Date getDate(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Date value);
3737

38-
Time getTime(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Time value);
38+
Time getTime(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Time value);
3939

40-
Timestamp getTimestamp(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Timestamp value);
40+
Timestamp getTimestamp(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Timestamp value);
4141

42-
InputStream getAsciiStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
42+
InputStream getAsciiStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
4343

44-
InputStream getUnicodeStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
44+
InputStream getUnicodeStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
4545

46-
InputStream getBinaryStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
46+
InputStream getBinaryStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
4747

48-
Object getObject(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Object value);
48+
Object getObject(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Object value);
4949

50-
Reader getCharacterStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Reader value);
50+
Reader getCharacterStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Reader value);
5151

52-
Ref getRef(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Ref value);
52+
Ref getRef(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Ref value);
5353

54-
Blob getBlob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Blob value);
54+
Blob getBlob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Blob value);
5555

56-
Clob getClob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Clob value);
56+
Clob getClob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Clob value);
5757

58-
Array getArray(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Array value);
58+
Array getArray(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Array value);
5959

60-
URL getURL(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, URL value);
60+
URL getURL(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, URL value);
6161

62-
NClob getNClob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, NClob value);
62+
NClob getNClob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, NClob value);
6363

64-
SQLXML getSQLXML(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, SQLXML value);
64+
SQLXML getSQLXML(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, SQLXML value);
6565

66-
String getNString(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, String value);
66+
String getNString(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, String value);
6767

68-
Reader getNCharacterStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Reader value);
68+
Reader getNCharacterStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Reader value);
6969

70-
RowId getRowId(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, RowId value);
70+
RowId getRowId(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, RowId value);
7171

72-
<T> T getObject(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, T value, Class<T> type);
72+
<T> T getObject(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, T value, Class<T> type);
7373

7474
}

0 commit comments

Comments
 (0)