Skip to content
Merged

Dev #189

Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-leave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
</parent>

<artifactId>example-interface</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.35</version>
<version>3.4.36</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>springboot-example</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>

<name>springboot-example</name>
<description>springboot-example project for Spring Boot</description>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>

<url>https://github.com/codingapi/springboot-framewrok</url>
<name>springboot-parent</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-authorization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.35</version>
<version>3.4.36</version>
</parent>

<name>springboot-starter-data-authorization</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.codingapi.springboot.authorization;

import com.codingapi.springboot.authorization.filter.DataAuthorizationFilter;
import com.codingapi.springboot.authorization.filter.DefaultSkipAuthorizationFilter;
import com.codingapi.springboot.authorization.handler.Condition;
import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
import com.codingapi.springboot.authorization.filter.SkipAuthorizationFilter;
import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
Expand All @@ -19,8 +22,19 @@ public class DataAuthorizationContext {

private final List<DataAuthorizationFilter> filters;

@Setter
private SkipAuthorizationFilter skipAuthorizationFilter;

private DataAuthorizationContext() {
this.filters = new ArrayList<>();
this.skipAuthorizationFilter = new DefaultSkipAuthorizationFilter();
}

/**
* 跳过拦截的处理机制
*/
public String skipSQLFilter(String sql){
return this.skipAuthorizationFilter.filter(sql);
}

/**
Expand All @@ -47,7 +61,7 @@ public void clearDataAuthorizationFilters() {
* @return T
* @param <T> 泛型
*/
public <T> T columnAuthorization(SQLInterceptState interceptState, String tableName, String columnName, T value) {
public <T> T columnAuthorization(SQLExecuteState interceptState, String tableName, String columnName, T value) {
if (interceptState != null && interceptState.hasIntercept()) {
String realTableName = interceptState.getTableName(tableName);
String realColumnName = interceptState.getColumnName(tableName,columnName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.codingapi.springboot.authorization.filter;

public class DefaultSkipAuthorizationFilter implements SkipAuthorizationFilter{

@Override
public String filter(String sql) {
return sql;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.codingapi.springboot.authorization.filter;

/**
* 跳过数据权限拦截处理机制
*/
public interface SkipAuthorizationFilter {

String filter(String sql);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.codingapi.springboot.authorization.handler;

import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;

import java.io.InputStream;
import java.io.Reader;
Expand All @@ -13,62 +13,62 @@
*/
public interface ColumnHandler {

String getString(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, String value);
String getString(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, String value);

boolean getBoolean(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, boolean value);
boolean getBoolean(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, boolean value);

byte getByte(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, byte value);
byte getByte(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, byte value);

short getShort(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, short value);
short getShort(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, short value);

int getInt(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, int value);
int getInt(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, int value);

long getLong(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, long value);
long getLong(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, long value);

float getFloat(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, float value);
float getFloat(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, float value);

double getDouble(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, double value);
double getDouble(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, double value);

BigDecimal getBigDecimal(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, BigDecimal value);
BigDecimal getBigDecimal(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, BigDecimal value);

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

Date getDate(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Date value);
Date getDate(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Date value);

Time getTime(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Time value);
Time getTime(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Time value);

Timestamp getTimestamp(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Timestamp value);
Timestamp getTimestamp(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Timestamp value);

InputStream getAsciiStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
InputStream getAsciiStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value);

InputStream getUnicodeStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
InputStream getUnicodeStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value);

InputStream getBinaryStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
InputStream getBinaryStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value);

Object getObject(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Object value);
Object getObject(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Object value);

Reader getCharacterStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Reader value);
Reader getCharacterStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Reader value);

Ref getRef(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Ref value);
Ref getRef(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Ref value);

Blob getBlob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Blob value);
Blob getBlob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Blob value);

Clob getClob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Clob value);
Clob getClob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Clob value);

Array getArray(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Array value);
Array getArray(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Array value);

URL getURL(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, URL value);
URL getURL(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, URL value);

NClob getNClob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, NClob value);
NClob getNClob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, NClob value);

SQLXML getSQLXML(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, SQLXML value);
SQLXML getSQLXML(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, SQLXML value);

String getNString(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, String value);
String getNString(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, String value);

Reader getNCharacterStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Reader value);
Reader getNCharacterStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Reader value);

RowId getRowId(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, RowId value);
RowId getRowId(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, RowId value);

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

}
Loading