This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 121f9466c [type:feat] Make an Apache Shenyu SSO authentication plugin
based on casdoor (#3934)
121f9466c is described below
commit 121f9466c18470c1b8c7c63360d92a203ffa6320
Author: jakiuncle <[email protected]>
AuthorDate: Thu Sep 29 10:45:58 2022 +0800
[type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor (#3934)
* [type:feature] Make an Apache Shenyu SSO authentication plugin based on
Casdoor
* [type:feature] Make an Apache Shenyu SSO authentication plugin based on
Casdoor
* [type:feature] Make an Apache Shenyu SSO authentication plugin based on
Casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based
* [type:feat] Make an Apache Shenyu SSO authentication plugin based
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
* [type:feat] Make an Apache Shenyu SSO authentication plugin based on
casdoor
Co-authored-by: xiaoyu <[email protected]>
---
db/init/mysql/schema.sql | 7 +
db/init/oracle/schema.sql | 23 ++-
db/init/pg/create-table.sql | 9 ++
db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql | 15 ++
db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql | 22 +++
db/upgrade/2.5.0-upgrade-2.5.1-pg.sql | 15 ++
.../src/main/resources/sql-script/h2/schema.sql | 10 +-
shenyu-bootstrap/pom.xml | 8 +
.../org/apache/shenyu/common/enums/PluginEnum.java | 7 +-
.../src/main/release-docs/LICENSE | 3 +
shenyu-plugin/pom.xml | 1 +
shenyu-plugin/shenyu-plugin-casdoor/pom.xml | 49 ++++++
.../shenyu/plugin/casdoor/CasdoorPlugin.java | 89 +++++++++++
.../plugin/casdoor/config/CasdoorConfig.java | 165 +++++++++++++++++++++
.../casdoor/handle/CasdoorPluginDateHandler.java | 51 +++++++
.../shenyu-spring-boot-starter-plugin/pom.xml | 1 +
.../pom.xml | 43 ++++++
.../plugin/casdoor/CasdoorPluginConfiguration.java | 50 +++++++
.../src/main/resources/META-INF/spring.factories | 19 +++
.../src/main/resources/META-INF/spring.provides | 18 +++
20 files changed, 601 insertions(+), 4 deletions(-)
diff --git a/db/init/mysql/schema.sql b/db/init/mysql/schema.sql
index 654000ad2..2dc5f0d55 100644
--- a/db/init/mysql/schema.sql
+++ b/db/init/mysql/schema.sql
@@ -666,6 +666,7 @@ INSERT INTO `plugin` VALUES ('34',
'loggingAliyunSls','{\"projectName\": \"sheny
INSERT INTO `plugin` VALUES ('35', 'loggingPulsar',
'{\"topic":\"shenyu-access-logging\", \"serviceUrl\":
\"pulsar://localhost:6650\"}', 'Logging', 185, 0, '2022-06-30 21:00:00',
'2022-06-30 21:00:00');
INSERT INTO `plugin` VALUES ('36', 'loggingTencentCls','{\"endpoint\":
\"ap-guangzhou.cls.tencentcs.com\", \"topic\": \"shenyu-topic\"}', 'Logging',
176, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
INSERT INTO `plugin` VALUES ('38', 'loggingClickHouse',
'{\"host\":\"127.0.0.1\",\"port\":\"8123\",\"databse\":\"shenyu-gateway\",\"username\":\"foo\",\"password\":\"bar\"}',
'Logging', 195, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
+INSERT INTO `plugin` VALUES ('39', 'casdoor',
'{\"endpoint\":\"localhost:8080\"}', 'Authentication', 40, 0, '2022-09-11
12:00:00', '2022-09-11 12:00:00');
-- ----------------------------
-- Table structure for plugin_handle
@@ -920,6 +921,12 @@ INSERT INTO `plugin_handle` VALUES ('1529402613204172742',
'8', 'loadBalance', '
INSERT INTO `plugin_handle` VALUES ('1529402613204172743', '10',
'flowRuleMaxQueueingTimeMs', 'flowRuleMaxQueueingTimeMs', 1, 2, 6,
'{\"required\":\"0\",\"defaultValue\":\"500\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172744', '10',
'flowRuleWarmUpPeriodSec', 'flowRuleWarmUpPeriodSec', 1, 2, 6,
'{\"required\":\"0\",\"defaultValue\":\"10\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172745', '14',
'addPrefixed', 'addPrefixed', 3, 2, 3,
'{\"required\":\"1\",\"defaultValue\":\"false\"}', '2022-09-27 12:00:00',
'2022-09-27 12:00:00');
+INSERT INTO `plugin_handle` VALUES ('1570590990341775360', '39', 'endpoint',
'casdoor endpoint', 2, 3, 0, '{\"required\":\"1\",\"rule\":\"\"}', '2022-09-27
12:00:00', '2022-09-27 12:00:00');
+INSERT INTO `plugin_handle` VALUES ('1570591047635968000', '39', 'client_id',
'client_id', 2, 3, 0, '{\"required\":\"1\",\"rule\":\"\"}', '2022-09-27
12:00:00', '2022-09-27 12:00:00');
+INSERT INTO `plugin_handle` VALUES ('1570591109623586816', '39',
'client_secrect', 'client_secrect', 2, 3, 0,
'{\"required\":\"1\",\"rule\":\"\"}', '2022-09-27 12:00:00', '2022-09-27
12:00:00');
+INSERT INTO `plugin_handle` VALUES ('1570591165374275584', '39',
'certificate', 'certificate', 2, 3, 0, '{\"required\":\"1\",\"rule\":\"\"}',
'2022-09-27 12:00:00', '2022-09-27 12:00:00');
+INSERT INTO `plugin_handle` VALUES ('1570591215131303936', '39',
'organization-name', 'organization-name', 2, 3, 0,
'{\"required\":\"1\",\"rule\":\"\"}', '2022-09-27 12:00:00', '2022-09-27
12:00:00');
+INSERT INTO `plugin_handle` VALUES ('1570591265492312064', '39',
'application-name', 'application-name', 2, 3, 0,
'{\"required\":\"1\",\"rule\":\"\"}', '2022-09-27 12:00:00', '2022-09-27
12:00:00');
INSERT INTO `plugin_handle` VALUES ('1572620652359245824', '18', 'keyword',
'keyword', 2, 2, 0, '{\"required\":\"0\",\"placeholder\":\"please use ‘;’ to
split keyword\",\"rule\":\"\"}', '2022-09-22 00:15:56.158', '2022-09-22
00:23:36.169');
INSERT INTO `plugin_handle` VALUES ('1572620783062147072', '18', 'maskType',
'maskType', 3, 2, 1,
'{\"required\":\"0\",\"defaultValue\":\"dataMaskByMD5\",\"rule\":\"\"}',
'2022-09-22 00:16:27.342', '2022-09-22 00:16:27.342');
INSERT INTO `plugin_handle` VALUES ('1572621008824754176', '18', 'maskStatus',
'maskStatus', 3, 2, 2,
'{\"required\":\"0\",\"defaultValue\":\"false\",\"rule\":\"\"}', '2022-09-22
00:17:21.150', '2022-09-22 00:17:21.150');
diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql
index 638811a89..8caaa41e7 100644
--- a/db/init/oracle/schema.sql
+++ b/db/init/oracle/schema.sql
@@ -857,6 +857,7 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO
plugin (id, name, conf
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('35', 'loggingPulsar',
'{"topic":"shenyu-access-logging", "serviceUrl": "pulsar://localhost:6650"}',
'Logging', 185, '0')
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('36', 'loggingTencentCls', '{"endpoint":
"ap-guangzhou.cls.tencentcs.com", "topic": "shenyu-topic"}', 'Logging', 176,
'0');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('38', 'loggingClickHouse',
'{"host":"127.0.0.1","port":"8123","databse":"shenyu-gateway","username":"foo","password":"bar"}',
'Logging', 195, '0');
+INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('39', 'casdoor',
'{"endpoint":"localhost:8080"}' ,'Authentication', 40, '0');
@@ -1547,6 +1548,24 @@ values ('1518229897214468229', '10',
'flowRuleWarmUpPeriodSec', 'flowRuleWarmUpP
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
VALUES ('1518229897214468230', '14', 'addPrefixed', 'addPrefixed', 3, 2, 3,
'{"required":"1","defaultValue":"false"}');
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570590990341775360', '39', 'endpoint', 'casdoor endpoint', 2, 3, 0,
'{"required":"1","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570591047635968000', '39', 'client_id', 'client_id', 2, 3, 0,
'{"required":"1","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570591109623586816', '39', 'client_secrect', 'client_secrect', 2, 3,
0, '{"required":"1","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570591165374275584', '39', 'certificate', 'certificate', 2, 3, 0,
'{"required":"1","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570591215131303936', '39', 'organization-name', 'organization-name',
2, 3, 0, '{"required":"1","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570591265492312064', '39', 'application-name', 'application-name',
2, 3, 0, '{"required":"1","rule":""}');
+
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
values ('1572620652359245824', '18', 'keyword', 'keyword', 2, 2, 0,
'{"required":"0","placeholder":"please use ‘;’ to split keyword","rule":""}');
@@ -1742,6 +1761,7 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */
INTO "resource" (id,
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status) VALUES('1534585531108564992',
'1534585430311051264', 'send', '', '', '', 2, 0, '', 1, 0,
'document:apirun:send', 1);
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status)VALUES ('1572525965625266176',
'1346777449787125760', 'SHENYU.BUTTON.SYSTEM.RESOURCE', '', '', '', 2, 6, '',
1, 0, 'system:plugin:resource', 1);
+
/* default permission */
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1351007708572688384', '1346358560427216896',
'1346775491550474240');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1357956838021890049', '1346358560427216896',
'1357956838021890048');
@@ -1801,5 +1821,4 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */
INTO permission (id, o
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1534577122279825408', '1346358560427216896',
'1534577121923309568');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1534585430587875328', '1346358560427216896',
'1534585430311051264');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1534585531389583360', '1346358560427216896',
'1534585531108564992');
-INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1572525965658820608', '1346358560427216896',
'1572525965625266176');
-commit;
\ No newline at end of file
+INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1572525965658820608', '1346358560427216896',
'1572525965625266176');
\ No newline at end of file
diff --git a/db/init/pg/create-table.sql b/db/init/pg/create-table.sql
index 51331bd72..718d5971b 100644
--- a/db/init/pg/create-table.sql
+++ b/db/init/pg/create-table.sql
@@ -742,6 +742,7 @@ INSERT INTO "public"."plugin" VALUES ('34',
'loggingAliyunSls', '{"projectName":
INSERT INTO "public"."plugin" VALUES ('35', 'loggingPulsar',
'{"topic":"shenyu-access-logging", "serviceUrl": "pulsar://localhost:6650"}',
'Logging', 185, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin" VALUES ('36', 'loggingTencentCls', '{"endpoint":
"ap-guangzhou.cls.tencentcs.com", "topic": "shenyu-topic"}', 'Logging', 176, 0,
'2022-06-30 21:00:00', '2022-06-30 21:00:00');
INSERT INTO "public"."plugin" VALUES ('38', 'loggingClickHouse',
'{"host":"127.0.0.1","port":"8123","databse":"shenyu-gateway","username":"foo","password":"bar"}',
'Logging', 195, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
+INSERT INTO "public"."plugin" VALUES ('39', 'casdoor',
'{"endpoint":"localhost:8080"}', 'Authentication', 40, 0, '2022-09-11
12:00:00', '2022-09-11 12:00:00');
-- ----------------------------
-- Table structure for plugin_handle
@@ -1008,6 +1009,14 @@ INSERT INTO "public"."plugin_handle" VALUES
('1529402613204172802', '8', 'loadBa
INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172803', '10',
'flowRuleMaxQueueingTimeMs', 'flowRuleMaxQueueingTimeMs', 1, 2, 6,
'{"required":"0","defaultValue":"500"}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172804', '10',
'flowRuleWarmUpPeriodSec', 'flowRuleWarmUpPeriodSec', 1, 2, 6,
'{"required":"0","defaultValue":"10"}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172805', '14',
'addPrefixed', 'addPrefixed', 3, 2, 3,
'{"required":"1","defaultValue":"false"}', '2022-09-27 12:00:00', '2022-09-27
12:00:00');
+
+INSERT INTO "public"."plugin_handle" VALUES ('1570590990341775360', '39',
'endpoint', 'casdoor endpoint', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1570591047635968000', '39',
'client_id', 'client_id', 2, 3, 0, '{"required":"1","rule":""}', '2022-09-16
09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1570591109623586816', '39',
'client_secrect', 'client_secrect', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1570591165374275584', '39',
'certificate', 'certificate', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1570591215131303936', '39',
'organization-name', 'organization-name', 2, 3, 0,
'{"required":"1","rule":""}', '2022-09-16 09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1570591265492312064', '39',
'application-name', 'application-name', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46', '2022-09-16 09:50:46');
+
INSERT INTO "public"."plugin_handle" VALUES ('1572620652359245824', '18',
'keyword', 'keyword', 2, 2, 0, '{"required":"0","placeholder":"please use ‘;’
to split keyword","rule":""}', '2022-09-22 00:15:56.158', '2022-09-22
00:23:36.169');
INSERT INTO "public"."plugin_handle" VALUES ('1572620783062147072', '18',
'maskType', 'maskType', 3, 2, 1,
'{"required":"0","defaultValue":"dataMaskByMD5","rule":""}', '2022-09-22
00:16:27.342', '2022-09-22 00:16:27.342');
INSERT INTO "public"."plugin_handle" VALUES ('1572621008824754176', '18',
'maskStatus', 'maskStatus', 3, 2, 2,
'{"required":"0","defaultValue":"false","rule":""}', '2022-09-22 00:17:21.150',
'2022-09-22 00:17:21.150');
diff --git a/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
b/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
index fcedccb84..7d87ef227 100644
--- a/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
+++ b/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
@@ -90,6 +90,21 @@ INSERT INTO `plugin_handle` VALUES ('1529402613204172744',
'10', 'flowRuleWarmUp
INSERT INTO `resource` VALUES ('1572525965625266176', '1346777449787125760',
'SHENYU.BUTTON.SYSTEM.RESOURCE', '', '', '',2, 6, '', 1, 0,
'system:plugin:resource', 1, '2022-09-28 11:50:58', '2022-09-28 11:50:58');
INSERT INTO `permission` VALUES ('1572525965658820608', '1346358560427216896',
'1572525965625266176', '2022-09-28 11:50:58', '2022-09-28 11:50:58');
+/*insert plugin for casdoor*/
+INSERT INTO `plugin` VALUES ('39', 'casdoor',
'{\"endpoint\":\"localhost:8080\"}', 'Authentication', 40, 0, '2022-09-11
12:00:00', '2022-09-11 12:00:00');
+
+/* insert plugin_handle data for plugin casdoor */
+INSERT INTO `plugin_handle` VALUES ('1570590990341775360', '39', 'endpoint',
'casdoor endpoint', 2, 3, 0, '{"required":"1","rule":""}', '2022-09-16
09:50:46.925', '2022-09-16 09:50:46.925');
+INSERT INTO `plugin_handle` VALUES ('1570591047635968000', '39', 'client_id',
'client_id', 2, 3, 0, '{"required":"1","rule":""}', '2022-09-16 09:50:46.925',
'2022-09-16 09:50:46.925');
+INSERT INTO `plugin_handle` VALUES ('1570591109623586816', '39',
'client_secrect', 'client_secrect', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46.925', '2022-09-16 09:50:46.925');
+INSERT INTO `plugin_handle` VALUES ('1570591165374275584', '39',
'certificate', 'certificate', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46.925', '2022-09-16 09:50:46.925');
+INSERT INTO `plugin_handle` VALUES ('1570591215131303936', '39',
'organization-name', 'organization-name', 2, 3, 0,
'{"required":"1","rule":""}', '2022-09-16 09:50:46.925', '2022-09-16
09:50:46.925');
+INSERT INTO `plugin_handle` VALUES ('1570591265492312064', '39',
'application-name', 'application-name', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46.925', '2022-09-16 09:50:46.925');
+
+INSERT INTO `plugin_handle` VALUES ('1529402613204172743', '10',
'flowRuleMaxQueueingTimeMs', 'flowRuleMaxQueueingTimeMs', 1, 2, 6,
'{\"required\":\"0\",\"defaultValue\":\"500\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1529402613204172744', '10',
'flowRuleWarmUpPeriodSec', 'flowRuleWarmUpPeriodSec', 1, 2, 6,
'{\"required\":\"0\",\"defaultValue\":\"10\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
+
+
/* fix issue 3966 */
INSERT INTO `plugin_handle` VALUES ('1529402613204172745', '14',
'addPrefixed', 'addPrefixed', 3, 2, 3,
'{\"required\":\"1\",\"defaultValue\":\"false\"}', '2022-09-27 12:00:00',
'2022-09-27 12:00:00');
INSERT INTO `shenyu_dict` VALUES ('1529402613195784282', 'addPrefixed',
'ADD_PREFIXED', 'open', 'true', '', 0, 1, '2022-09-27 12:00:00', '2022-09-27
12:00:00');
diff --git a/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
b/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
index e28388e51..8c3f40db3 100644
--- a/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
+++ b/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
@@ -174,6 +174,28 @@ values ('1518229897214468229', '10',
'flowRuleWarmUpPeriodSec', 'flowRuleWarmUpP
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO resource (id,
parent_id, title, name, url, component, resource_type, sort, icon, is_leaf,
is_route, perms, status)VALUES ('1572525965625266176', '1346777449787125760',
'SHENYU.BUTTON.SYSTEM.RESOURCE', '', '', '', 2, 6, '', 1, 0,
'system:plugin:resource', 1);
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1572525965658820608', '1346358560427216896',
'1572525965625266176');
+/*insert plugin for casdoor*/
+INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('39', 'casdoor',
'{"endpoint":"localhost:8080"}' ,'Authentication', 40, '0');
+
+/* insert plugin_handle data for plugin casdoor */
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570590990341775360', '39', 'endpoint', 'casdoor endpoint', 2, 3, 0,
'{"required":"1","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570591047635968000', '39', 'client_id', 'client_id', 2, 3, 0,
'{"required":"1","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570591109623586816', '39', 'client_secrect', 'client_secrect', 2, 3,
0, '{"required":"1","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570591165374275584', '39', 'certificate', 'certificate', 2, 3, 0,
'{"required":"1","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570591215131303936', '39', 'organization-name', 'organization-name',
2, 3, 0, '{"required":"1","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1570591265492312064', '39', 'application-name', 'application-name',
2, 3, 0, '{"required":"1","rule":""}');
+
/* fix issue 3966 */
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
diff --git a/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
b/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
index 39ae31b51..7a06275e3 100644
--- a/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
+++ b/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
@@ -92,6 +92,21 @@ INSERT INTO "public"."plugin_handle" VALUES
('1529402613204172804', '10', 'flowR
INSERT INTO "public"."resource" VALUES ('1572525965625266176',
'1346777449787125760', 'SHENYU.BUTTON.SYSTEM.RESOURCE', '', '', '', 2, 6, '',
1, 0, 'system:plugin:resource', 1, '2022-09-28 11:50:58', '2022-09-28
11:50:58');
INSERT INTO "public"."permission" VALUES ('1572525965658820608',
'1346358560427216896', '1572525965625266176', '2022-09-28 11:50:58',
'2022-09-28 11:50:58');
+/*insert plugin for casdoor*/
+INSERT INTO "public"."plugin" VALUES ('39', 'casdoor',
'{"endpoint":"localhost:8080"}', 'Authentication', 40, 0, '2022-09-11
12:00:00', '2022-09-11 12:00:00');
+
+/* insert plugin_handle data for plugin casdoor */
+INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172802', '8',
'loadBalance', 'loadStrategy', 3, 2, 3,
'{"defaultValue":"roundRobin","rule":""}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1570590990341775360', '39',
'endpoint', 'casdoor endpoint', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1570591047635968000', '39',
'client_id', 'client_id', 2, 3, 0, '{"required":"1","rule":""}', '2022-09-16
09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1570591109623586816', '39',
'client_secrect', 'client_secrect', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1570591165374275584', '39',
'certificate', 'certificate', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1570591215131303936', '39',
'organization-name', 'organization-name', 2, 3, 0,
'{"required":"1","rule":""}', '2022-09-16 09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1570591265492312064', '39',
'application-name', 'application-name', 2, 3, 0, '{"required":"1","rule":""}',
'2022-09-16 09:50:46', '2022-09-16 09:50:46');
+INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172803', '10',
'flowRuleMaxQueueingTimeMs', 'flowRuleMaxQueueingTimeMs', 1, 2, 6,
'{"required":"0","defaultValue":"500"}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172804', '10',
'flowRuleWarmUpPeriodSec', 'flowRuleWarmUpPeriodSec', 1, 2, 6,
'{"required":"0","defaultValue":"10"}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
+
+
/* fix issue 3966 */
INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172805', '14',
'addPrefixed', 'addPrefixed', 3, 2, 3,
'{"required":"1","defaultValue":"false"}', '2022-09-27 12:00:00', '2022-09-27
12:00:00');
INSERT INTO "public"."shenyu_dict" VALUES ('1529402613195784282',
'addPrefixed', 'ADD_PREFIXED', 'open', 'true', '', 0, 1, '2022-09-27 12:00:00',
'2022-09-27 12:00:00');
diff --git a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
index c8cf0d04c..58fd72e3f 100755
--- a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
+++ b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
@@ -408,7 +408,7 @@ INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`,
`config`, `enabled`)
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,
`enabled`) VALUES ('35', 'loggingPulsar', 'Logging', 185,
'{"topic":"shenyu-access-logging", "serviceUrl": "pulsar://localhost:6650"}',
'0');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,
`enabled`) VALUES ('36', 'loggingTencentCls', 'Logging', 176, '{"endpoint":
"ap-guangzhou.cls.tencentcs.com", "topic": "shenyu-topic"}', '0');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,
`enabled`) VALUES ('38', 'loggingClickHouse', 'Logging', 195,
'{"host":"127.0.0.1","port":"8123","databse":"shenyu-gateway","username":"foo","password":"bar"}',
'0');
-
+INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,
`enabled`) VALUES ('39', 'casdoor', 'Authentication', 40,
'{"endpoint":"localhost:8080"}', '0');
/*insert plugin_handle data for sentinel*/
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613195784246', '10', 'flowRuleGrade', 'flowRuleGrade', 3, 2, 8,
'{"required":"1","defaultValue":"1","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613199978496', '10', 'flowRuleControlBehavior',
'flowRuleControlBehavior', 3, 2, 5,
'{"required":"1","defaultValue":"0","rule":""}');
@@ -666,6 +666,12 @@ INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1572621008824754176', '38', 'maskStatus', 'maskStatus', 3, 2, 2,
'{"required":"0","defaultValue":"false","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1570590990341775360', '39', 'endpoint', 'casdoor endpoint', 2, 3, 0,
'{"required":"1","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1570591047635968000', '39', 'client_id', 'client_id', 2, 3, 0,
'{"required":"1","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1570591109623586816', '39', 'client_secrect', 'client_secrect', 2, 3, 0,
'{"required":"1","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1570591165374275584', '39', 'certificate', 'certificate', 2, 3, 0,
'{"required":"1","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1570591215131303936', '39', 'organization-name', 'organization-name', 2, 3,
0, '{"required":"1","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1570591265492312064', '39', 'application-name', 'application-name', 2, 3, 0,
'{"required":"1","rule":""}');
/** insert resource for resource */
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`)
VALUES('1346775491550474240','','SHENYU.MENU.PLUGIN.LIST','plug','/plug','PluginList','0','0','dashboard','0','0','','1');
@@ -799,3 +805,5 @@ INSERT IGNORE INTO `permission` (`id`, `object_id`,
`resource_id`) VALUES ('1357
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`) VALUES
('1534577122279825408', '1346358560427216896', '1534577121923309568');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`) VALUES
('1534585430587875328', '1346358560427216896', '1534585430311051264');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`) VALUES
('1534585531389583360', '1346358560427216896', '1534585531108564992');
+
+
diff --git a/shenyu-bootstrap/pom.xml b/shenyu-bootstrap/pom.xml
index 2bc54d1b0..98f413f72 100644
--- a/shenyu-bootstrap/pom.xml
+++ b/shenyu-bootstrap/pom.xml
@@ -152,6 +152,14 @@
</dependency>
<!--shenyu jwt end-->
+ <!--shenyu casdoor plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-casdoor</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--shenyu auth plugin end-->
+
<!-- shenyu modify response plugin start-->
<dependency>
<groupId>org.apache.shenyu</groupId>
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
index 4d229d095..dc0055afe 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
@@ -66,7 +66,12 @@ public enum PluginEnum {
* OAuth2 plugin enum.
*/
OAUTH2(40, 0, "oauth2"),
-
+
+ /**
+ * Casdoor plugin enum.
+ */
+ CASDOOR(40, 0, "casdoor"),
+
/**
* Waf plugin enum.
*/
diff --git a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
index 5acda039d..c272bb625 100644
--- a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
+++ b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
@@ -512,6 +512,9 @@ The text of each license is the standard Apache 2.0 license.
aliyun-log 0.6.57: https://github.com/aliyun/aliyun-log-java-producer,
Apache 2.0
aliyun-log-producer 0.3.10:
https://github.com/aliyun/aliyun-log-java-producer, Apache 2.0
tencentcloud-cls-sdk-java 1.0.9:
https://github.com/TencentCloud/tencentcloud-cls-sdk-java, Apache 2.0
+ casdoor-java-sdk 1.9.0: https://github.com/casdoor/casdoor-java-sdk,
Apache 2.0
+ nimbus-jose-jwt 9.10: https://connect2id.com/products/nimbus-jose-jwt,
Apache 2.0
+ oltu 1.0.2: https://oltu.apache.org/, Apache 2.0
========================================================================
BSD licenses
diff --git a/shenyu-plugin/pom.xml b/shenyu-plugin/pom.xml
index a53ee2345..fe3341744 100644
--- a/shenyu-plugin/pom.xml
+++ b/shenyu-plugin/pom.xml
@@ -62,5 +62,6 @@
<module>shenyu-plugin-cache</module>
<module>shenyu-plugin-logging</module>
<module>shenyu-plugin-mock</module>
+ <module>shenyu-plugin-casdoor</module>
</modules>
</project>
diff --git a/shenyu-plugin/shenyu-plugin-casdoor/pom.xml
b/shenyu-plugin/shenyu-plugin-casdoor/pom.xml
new file mode 100644
index 000000000..88ce92c9c
--- /dev/null
+++ b/shenyu-plugin/shenyu-plugin-casdoor/pom.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You 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>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-plugin</artifactId>
+ <version>2.5.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>shenyu-plugin-casdoor</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-plugin-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.casbin</groupId>
+ <artifactId>casdoor-java-sdk</artifactId>
+ <version>1.9.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git
a/shenyu-plugin/shenyu-plugin-casdoor/src/main/java/org/apache/shenyu/plugin/casdoor/CasdoorPlugin.java
b/shenyu-plugin/shenyu-plugin-casdoor/src/main/java/org/apache/shenyu/plugin/casdoor/CasdoorPlugin.java
new file mode 100644
index 000000000..c3548e86d
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-casdoor/src/main/java/org/apache/shenyu/plugin/casdoor/CasdoorPlugin.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shenyu.plugin.casdoor;
+
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.common.utils.Singleton;
+import org.apache.shenyu.plugin.api.ShenyuPluginChain;
+import org.apache.shenyu.plugin.api.result.ShenyuResultEnum;
+import org.apache.shenyu.plugin.api.result.ShenyuResultWrap;
+import org.apache.shenyu.plugin.api.utils.WebFluxResultUtils;
+import org.apache.shenyu.plugin.base.AbstractShenyuPlugin;
+import org.casbin.casdoor.entity.CasdoorUser;
+import org.casbin.casdoor.service.CasdoorAuthService;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+import java.util.Objects;
+
+public class CasdoorPlugin extends AbstractShenyuPlugin {
+
+ @Override
+ protected Mono<Void> doExecute(final ServerWebExchange exchange, final
ShenyuPluginChain chain, final SelectorData selector, final RuleData rule) {
+ CasdoorAuthService casdoorAuthService =
Singleton.INST.get(CasdoorAuthService.class);
+ ServerHttpRequest request = exchange.getRequest();
+ String token =
exchange.getRequest().getHeaders().getFirst(HttpHeaders.AUTHORIZATION);
+ if (Objects.nonNull(token)) {
+ CasdoorUser casdoorUser = casdoorAuthService.parseJwtToken(token);
+ if (Objects.nonNull(casdoorUser)) {
+ return chain.execute(handleToken(exchange, casdoorUser));
+ }
+ }
+ MultiValueMap<String, String> queryParams = request.getQueryParams();
+ String code = queryParams.getFirst("code");
+ String state = queryParams.getFirst("state");
+ if (Objects.nonNull(code) || Objects.nonNull(state)) {
+ token = casdoorAuthService.getOAuthToken(code, state);
+ CasdoorUser casdoorUser = casdoorAuthService.parseJwtToken(token);
+ if (Objects.nonNull(casdoorUser)) {
+ return chain.execute(handleToken(exchange, casdoorUser));
+ }
+ }
+ Object error = ShenyuResultWrap.error(exchange,
ShenyuResultEnum.ERROR_TOKEN);
+ return WebFluxResultUtils.result(exchange, error);
+ }
+
+ @Override
+ public int getOrder() {
+ return PluginEnum.CASDOOR.getCode();
+ }
+
+ @Override
+ public String named() {
+ return PluginEnum.CASDOOR.getName();
+ }
+
+ @Override
+ public boolean skip(final ServerWebExchange exchange) {
+ return false;
+ }
+
+ private ServerWebExchange handleToken(final ServerWebExchange exchange,
final CasdoorUser casdoorUser) {
+ ServerHttpRequest.Builder mutate = exchange.getRequest().mutate();
+ mutate.header("name", casdoorUser.getName());
+ mutate.header("id", casdoorUser.getId());
+ mutate.header("organization", casdoorUser.getOwner());
+ return exchange.mutate().request(mutate.build()).build();
+ }
+
+}
diff --git
a/shenyu-plugin/shenyu-plugin-casdoor/src/main/java/org/apache/shenyu/plugin/casdoor/config/CasdoorConfig.java
b/shenyu-plugin/shenyu-plugin-casdoor/src/main/java/org/apache/shenyu/plugin/casdoor/config/CasdoorConfig.java
new file mode 100644
index 000000000..6ec268d09
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-casdoor/src/main/java/org/apache/shenyu/plugin/casdoor/config/CasdoorConfig.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shenyu.plugin.casdoor.config;
+
+public class CasdoorConfig {
+
+ private String endpoint;
+
+ private String clientId;
+
+ private String clientSecret;
+
+ private String certificate;
+
+ private String organizationName;
+
+ private String applicationName;
+
+ public CasdoorConfig(final String endpoint, final String clientId, final
String clientSecret, final String certificate, final String organizationName,
final String applicationName) {
+ this.endpoint = endpoint;
+ this.clientId = clientId;
+ this.clientSecret = clientSecret;
+ this.certificate = certificate;
+ this.organizationName = organizationName;
+ this.applicationName = applicationName;
+ }
+
+ public CasdoorConfig() {
+ }
+
+ /**
+ * Gets endpoint.
+ *
+ * @return the endpoint
+ */
+ public String getEndpoint() {
+ return this.endpoint;
+ }
+
+ /**
+ * Gets clientId.
+ *
+ * @return the clientId
+ */
+ public String getClientId() {
+ return this.clientId;
+ }
+
+ /**
+ * Gets clientSecret.
+ *
+ * @return the clientSecret
+ */
+ public String getClientSecret() {
+ return this.clientSecret;
+ }
+
+ /**
+ * Gets certificate.
+ *
+ * @return the certificate
+ */
+ public String getCertificate() {
+ return this.certificate;
+ }
+
+ /**
+ * Gets organizationName.
+ *
+ * @return the organizationName
+ */
+ public String getOrganizationName() {
+ return this.organizationName;
+ }
+
+ /**
+ * Gets applicationName.
+ *
+ * @return the applicationName
+ */
+ public String getApplicationName() {
+ return this.applicationName;
+ }
+
+ /**
+ * Sets endpoint.
+ *
+ * @param endpoint the endpoint
+ */
+ public void setEndpoint(final String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ /**
+ * Sets clientId.
+ *
+ * @param clientId the clientId
+ */
+ public void setClientId(final String clientId) {
+ this.clientId = clientId;
+ }
+
+ /**
+ * Sets clientSecret.
+ *
+ * @param clientSecret the clientSecret
+ */
+ public void setClientSecret(final String clientSecret) {
+ this.clientSecret = clientSecret;
+ }
+
+ /**
+ * Sets certificate.
+ *
+ * @param certificate the certificate
+ */
+ public void setCertificate(final String certificate) {
+ this.certificate = certificate;
+ }
+
+ /**
+ * Sets organizationName.
+ *
+ * @param organizationName the organizationName
+ */
+ public void setOrganizationName(final String organizationName) {
+ this.organizationName = organizationName;
+ }
+
+ /**
+ * Sets applicationName.
+ *
+ * @param applicationName the applicationName
+ */
+ public void setApplicationName(final String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ @Override
+ public String toString() {
+ return "authConfig{"
+ + "endpoint='" + endpoint + '\''
+ + ", clientId='" + clientId + '\''
+ + ", clientSecret='" + clientSecret + '\''
+ + ", certificate='" + certificate + '\''
+ + ", organizationName='" + organizationName + '\''
+ + ", applicationName='" + applicationName + '\''
+ + '}';
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-casdoor/src/main/java/org/apache/shenyu/plugin/casdoor/handle/CasdoorPluginDateHandler.java
b/shenyu-plugin/shenyu-plugin-casdoor/src/main/java/org/apache/shenyu/plugin/casdoor/handle/CasdoorPluginDateHandler.java
new file mode 100644
index 000000000..1a48e7332
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-casdoor/src/main/java/org/apache/shenyu/plugin/casdoor/handle/CasdoorPluginDateHandler.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shenyu.plugin.casdoor.handle;
+
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.common.utils.GsonUtils;
+import org.apache.shenyu.common.utils.Singleton;
+import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
+import org.casbin.casdoor.config.CasdoorConfig;
+import org.casbin.casdoor.service.CasdoorAuthService;
+
+import java.util.Map;
+import java.util.Optional;
+
+public class CasdoorPluginDateHandler implements PluginDataHandler {
+ @Override
+ public void handlerPlugin(final PluginData pluginData) {
+ Map<String, String> configMap =
GsonUtils.getInstance().toObjectMap(pluginData.getConfig(), String.class);
+ final String endpoint =
Optional.ofNullable(configMap.get("endpoint")).orElse("");
+ final String clientSecrect =
Optional.ofNullable(configMap.get("client_secrect")).orElse("");
+ final String clientId =
Optional.ofNullable(configMap.get("client_id")).orElse("");
+ String certificate =
Optional.ofNullable(configMap.get("certificate")).orElse("");
+ certificate = certificate.replace("\\n", "\n");
+ String organization =
Optional.ofNullable(configMap.get("organization-name")).orElse("");
+ String application =
Optional.ofNullable(configMap.get("application-name")).orElse("");
+ CasdoorConfig casdoorConfig = new CasdoorConfig(endpoint, clientId,
clientSecrect, certificate, organization, application);
+ CasdoorAuthService casdoorAuthService = new
CasdoorAuthService(casdoorConfig);
+ Singleton.INST.single(CasdoorAuthService.class, casdoorAuthService);
+ }
+
+ @Override
+ public String pluginNamed() {
+ return PluginEnum.CASDOOR.getName();
+ }
+}
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/pom.xml
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/pom.xml
index 5a574cc5c..3dae402ef 100644
--- a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/pom.xml
+++ b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/pom.xml
@@ -67,5 +67,6 @@
<module>shenyu-spring-boot-starter-plugin-logging-pulsar</module>
<module>shenyu-spring-boot-starter-plugin-logging-tencent-cls</module>
<module>shenyu-spring-boot-starter-plugin-logging-clickhouse</module>
+ <module>shenyu-spring-boot-starter-plugin-casdoor</module>
</modules>
</project>
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/pom.xml
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/pom.xml
new file mode 100644
index 000000000..b4925ee2f
--- /dev/null
+++
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You 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>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin</artifactId>
+ <version>2.5.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>shenyu-spring-boot-starter-plugin-casdoor</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-autoconfigure</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-plugin-casdoor</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/src/main/java/org/apache/shenyu/springboot/starter/plugin/casdoor/CasdoorPluginConfiguration.java
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/src/main/java/org/apache/shenyu/springboot/starter/plugin/casdoor/CasdoorPluginConfiguration.java
new file mode 100644
index 000000000..03f33b058
--- /dev/null
+++
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/src/main/java/org/apache/shenyu/springboot/starter/plugin/casdoor/CasdoorPluginConfiguration.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shenyu.springboot.starter.plugin.casdoor;
+
+import org.apache.shenyu.plugin.api.ShenyuPlugin;
+import org.apache.shenyu.plugin.casdoor.CasdoorPlugin;
+import org.apache.shenyu.plugin.casdoor.handle.CasdoorPluginDateHandler;
+import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ConditionalOnProperty(value = {"shenyu.plugins.casdoor.enabled"}, havingValue
= "true", matchIfMissing = true)
+public class CasdoorPluginConfiguration {
+
+ /**
+ * the casdoor plugin.
+ * @return the shenyu plugin
+ */
+ @Bean
+ public ShenyuPlugin authPathPlugin() {
+ return new CasdoorPlugin();
+ }
+
+ /**
+ * Casdoor plugin data handler.
+ *
+ * @return the plugin data handler
+ */
+ @Bean
+ public PluginDataHandler authPluginDataHandler() {
+ return new CasdoorPluginDateHandler();
+ }
+}
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/src/main/resources/META-INF/spring.factories
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/src/main/resources/META-INF/spring.factories
new file mode 100644
index 000000000..927d3720a
--- /dev/null
+++
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.shenyu.springboot.starter.plugin.casdoor.CasdoorPluginConfiguration
\ No newline at end of file
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/src/main/resources/META-INF/spring.provides
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/src/main/resources/META-INF/spring.provides
new file mode 100644
index 000000000..b0c57623f
--- /dev/null
+++
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-casdoor/src/main/resources/META-INF/spring.provides
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+provides: shenyu-spring-boot-starter-plugin-casdoor