You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by sa...@apache.org on 2021/07/19 14:01:04 UTC
[incubator-shenyu] branch master updated: [ISSUE #1796]Add jwt and
oauth2 plugin sql (#1797)
This is an automated email from the ASF dual-hosted git repository.
sabersola pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new b7a799d [ISSUE #1796]Add jwt and oauth2 plugin sql (#1797)
b7a799d is described below
commit b7a799db515b099018355b8f4e609e22b28f6ee7
Author: ttttangzhen <28...@qq.com>
AuthorDate: Mon Jul 19 22:00:56 2021 +0800
[ISSUE #1796]Add jwt and oauth2 plugin sql (#1797)
* add jwt sql
* add oauth2 sql
* remove white space
* fix typo
---
.../src/main/resources/META-INF/schema.h2.sql | 28 ++++++++++++++++++++++
.../src/main/resources/META-INF/schema.sql | 28 ++++++++++++++++++++++
shenyu-bootstrap/pom.xml | 6 +++++
.../apache/shenyu/common/constant/Constants.java | 10 ++++++++
.../plugin/jwt/handle/JwtPluginDataHandler.java | 15 ++++++++++--
.../apache/shenyu/plugin/jwt/JwtPluginTest.java | 2 +-
.../jwt/handle/JwtPluginDataHandlerTest.java | 9 +++++--
7 files changed, 93 insertions(+), 5 deletions(-)
diff --git a/shenyu-admin/src/main/resources/META-INF/schema.h2.sql b/shenyu-admin/src/main/resources/META-INF/schema.h2.sql
index 11b1097..870c695 100644
--- a/shenyu-admin/src/main/resources/META-INF/schema.h2.sql
+++ b/shenyu-admin/src/main/resources/META-INF/schema.h2.sql
@@ -436,6 +436,10 @@ INSERT IGNORE INTO plugin_handle (`id`,`plugin_id`,`field`,`label`,`data_type`,`
/*insert plugin_handle data for request*/
INSERT IGNORE INTO plugin_handle (`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`) VALUES ('86', '20', 'ruleHandlePageType', 'ruleHandlePageType', 3, 3, 0, '{"required":"0","rule":""}', '2021-05-27 23:43:53', '2021-05-30 19:58:28');
+/*insert plugin_handle data for plugin jwt*/
+INSERT IGNORE INTO plugin_handle (`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`) VALUES ('89','19' ,'secretKey','secretKey',2, 3, 0, null, '2020-11-09 01:19:10', '2020-11-09 01:19:10');
+INSERT IGNORE INTO plugin_handle (`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`) VALUES ('90','19' ,'filterPath','filterPath',2, 3, 1, null, '2021-06-12 19:17:10', '2021-06-12 19:17:10');
+
/** insert permission role for role */
INSERT IGNORE INTO `role` (`id`,`role_name`,`description`,`date_created`,`date_updated`) VALUES ('1346358560427216896', 'super', '超级管理员', '2021-01-05 01:31:10', '2021-01-08 17:00:07');
INSERT IGNORE INTO `role` (`id`,`role_name`,`description`,`date_created`,`date_updated`) VALUES ('1385482862971723776', 'default', '普通用户', '2021-04-23 14:37:10', '2021-04-23 14:38:39');
@@ -728,6 +732,18 @@ INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `compo
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768292343119', '1347028169120821250', 'SHENYU.BUTTON.PLUGIN.RULE.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:jwtRule:query', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768296538120', '1347028169120821250', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:jwt:modify', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+/** insert oauth2 plugin's resource */
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1347028169120821251', '1346775491550474240', 'oauth2', 'oauth2', '/plug/oauth2', 'oauth2', 1, 18, 'safety', 0, 0, '', 1, '2021-06-18 21:00:00', '2021-06-18 21:00:00');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768204263121', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Selector:add', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768216846122', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.SELECTOR.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Selector:delete', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768225234123', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Selector:edit', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768233623124', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Selector:query', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768246206125', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.RULE.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Rule:add', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768275566126', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.RULE.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Rule:delete', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768283955127', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.RULE.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Rule:edit', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768292343128', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.RULE.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Rule:query', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768296538129', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2:modify', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+
/** insert param-mapping plugin's resource */
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1405534378660888576', '1346775491550474240', 'param_mapping', 'param_mapping', '/plug/param_mapping', 'param_mapping', 1, 0, 'block', 0, 0, '', 1, '2021-06-17 22:34:44', '2021-06-17 22:34:44');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1405534378971267072', '1405534378660888576', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:param_mappingSelector:add', 1, '2021-06-17 22:34:44', '2021-06-17 22:34:44');
@@ -1021,6 +1037,18 @@ INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768283955008', '1346358560427216896', '1397547768292343119', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768292343009', '1346358560427216896', '1397547768296538120', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+/** add oauth2 plugin's permissions */
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768300732011', '1346358560427216896', '1347028169120821251', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768162320011', '1346358560427216896', '1397547768204263121', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768208457012', '1346358560427216896', '1397547768216846122', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768216846013', '1346358560427216896', '1397547768225234123', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768225234014', '1346358560427216896', '1397547768233623124', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768233623015', '1346358560427216896', '1397547768246206125', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768246206016', '1346358560427216896', '1397547768275566126', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768275566017', '1346358560427216896', '1397547768283955127', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768283955018', '1346358560427216896', '1397547768292343128', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768292343019', '1346358560427216896', '1397547768296538129', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+
/** add param-mapping plugin's permissions */
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1405534378686054400', '1346358560427216896', '1405534378660888576', '2021-06-17 22:34:44', '2021-06-17 22:34:44');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1405534378979655680', '1346358560427216896', '1405534378971267072', '2021-06-17 22:34:44', '2021-06-17 22:34:44');
diff --git a/shenyu-admin/src/main/resources/META-INF/schema.sql b/shenyu-admin/src/main/resources/META-INF/schema.sql
index 8b50fb8..cce50d8 100644
--- a/shenyu-admin/src/main/resources/META-INF/schema.sql
+++ b/shenyu-admin/src/main/resources/META-INF/schema.sql
@@ -439,6 +439,10 @@ INSERT IGNORE INTO plugin_handle (`id`,`plugin_id`,`field`,`label`,`data_type`,`
/*insert plugin_handle data for request*/
INSERT IGNORE INTO plugin_handle (`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`) VALUES ('86', '20', 'ruleHandlePageType', 'ruleHandlePageType', 3, 3, 0, '{"required":"0","rule":""}', '2021-05-27 23:43:53', '2021-05-30 19:58:28');
+/*insert plugin_handle data for plugin jwt*/
+INSERT IGNORE INTO plugin_handle (`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`) VALUES ('89','19' ,'secretKey','secretKey',2, 3, 0, null, '2020-11-09 01:19:10', '2020-11-09 01:19:10');
+INSERT IGNORE INTO plugin_handle (`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`) VALUES ('90','19' ,'filterPath','filterPath',2, 3, 1, null, '2021-06-12 19:17:10', '2021-06-12 19:17:10');
+
/** insert permission role for role */
INSERT IGNORE INTO `role` (`id`,`role_name`,`description`,`date_created`,`date_updated`) VALUES ('1346358560427216896', 'super', '超级管理员', '2021-01-05 01:31:10', '2021-01-08 17:00:07');
INSERT IGNORE INTO `role` (`id`,`role_name`,`description`,`date_created`,`date_updated`) VALUES ('1385482862971723776', 'default', '普通用户', '2021-04-23 14:37:10', '2021-04-23 14:38:39');
@@ -714,6 +718,18 @@ INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `compo
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1398994252666667008', '1398994252528254976', 'SHENYU.BUTTON.PLUGIN.RULE.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:modifyResponseRule:query', 1, '2021-05-30 21:26:37', '2021-05-30 21:26:36');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1398994252679249920', '1398994252528254976', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:modifyResponse:modify', 1, '2021-05-30 21:26:37', '2021-05-30 21:26:36');
+/** insert oauth2 plugin's resource */
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1347028169120821251', '1346775491550474240', 'oauth2', 'oauth2', '/plug/oauth2', 'oauth2', 1, 18, 'safety', 0, 0, '', 1, '2021-06-18 21:00:00', '2021-06-18 21:00:00');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768204263121', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Selector:add', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768216846122', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.SELECTOR.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Selector:delete', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768225234123', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Selector:edit', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768233623124', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Selector:query', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768246206125', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.RULE.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Rule:add', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768275566126', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.RULE.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Rule:delete', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768283955127', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.RULE.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Rule:edit', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768292343128', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.RULE.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2Rule:query', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1397547768296538129', '1347028169120821251', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:oauth2:modify', 1, '2021-06-18 21:38:48', '2021-06-18 21:38:47');
+
/** insert jwt plugin's resource */
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1347028169120821250', '1346775491550474240', 'jwt', 'jwt', '/plug/jwt', 'jwt', 1, 16, 'key', 0, 0, '', 1, '2021-06-18 21:00:00', '2021-06-18 21:00:00');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES('1390309613569036001', '1347028169120821250', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:jwtSelector:query', 1, '2021-05-06 22:16:57', '2021-05-06 22:37:00');
@@ -1012,6 +1028,18 @@ INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1398994252666667009', '1346358560427216896', '1398994252666667008', '2021-05-30 21:26:37', '2021-05-30 21:26:36');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1398994252679249921', '1346358560427216896', '1398994252679249920', '2021-05-30 21:26:37', '2021-05-30 21:26:36');
+/** add oauth2 plugin's permissions */
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768300732011', '1346358560427216896', '1347028169120821251', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768162320011', '1346358560427216896', '1397547768204263121', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768208457012', '1346358560427216896', '1397547768216846122', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768216846013', '1346358560427216896', '1397547768225234123', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768225234014', '1346358560427216896', '1397547768233623124', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768233623015', '1346358560427216896', '1397547768246206125', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768246206016', '1346358560427216896', '1397547768275566126', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768275566017', '1346358560427216896', '1397547768283955127', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768283955018', '1346358560427216896', '1397547768292343128', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768292343019', '1346358560427216896', '1397547768296538129', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
+
/** add jwt plugin's permissions */
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768300732010', '1346358560427216896', '1347028169120821250', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1397547768162320001', '1346358560427216896', '1397547768204263112', '2021-05-26 21:38:48', '2021-05-26 21:38:47');
diff --git a/shenyu-bootstrap/pom.xml b/shenyu-bootstrap/pom.xml
index 9fdabc7..d9417b4 100644
--- a/shenyu-bootstrap/pom.xml
+++ b/shenyu-bootstrap/pom.xml
@@ -170,6 +170,12 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-jwt</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- <dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-client</artifactId>
diff --git a/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java b/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
index 4a71e68..7779883 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
@@ -309,6 +309,16 @@ public interface Constants {
boolean AUTOMATIC_TRANSITION_FROM_OPEN_TO_HALF_OPEN_ENABLED = false;
/**
+ * jwt handle key for secretKey.
+ */
+ String SECRET_KEY = "secretKey";
+
+ /**
+ * jwt handle key for filterPath.
+ */
+ String FILTER_PATH = "filterPath";
+
+ /**
* Enable the flow rule.
*/
int SENTINEL_ENABLE_FLOW_RULE = 1;
diff --git a/shenyu-plugin/shenyu-plugin-jwt/src/main/java/org/apache/shenyu/plugin/jwt/handle/JwtPluginDataHandler.java b/shenyu-plugin/shenyu-plugin-jwt/src/main/java/org/apache/shenyu/plugin/jwt/handle/JwtPluginDataHandler.java
index 55d6390..d1e3c68 100644
--- a/shenyu-plugin/shenyu-plugin-jwt/src/main/java/org/apache/shenyu/plugin/jwt/handle/JwtPluginDataHandler.java
+++ b/shenyu-plugin/shenyu-plugin-jwt/src/main/java/org/apache/shenyu/plugin/jwt/handle/JwtPluginDataHandler.java
@@ -17,6 +17,8 @@
package org.apache.shenyu.plugin.jwt.handle;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.common.constant.Constants;
import org.apache.shenyu.common.dto.PluginData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.utils.GsonUtils;
@@ -24,14 +26,23 @@ import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
import org.apache.shenyu.plugin.base.utils.Singleton;
import org.apache.shenyu.plugin.jwt.config.JwtConfig;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
/**
- * Configuration data of the jwt plugin.
+ * Configuration data of the jwt plugin.
*/
public class JwtPluginDataHandler implements PluginDataHandler {
@Override
public void handlerPlugin(final PluginData pluginData) {
- JwtConfig jwtConfig = GsonUtils.getInstance().fromJson(pluginData.getConfig(), JwtConfig.class);
+ Map<String, String> configMap = GsonUtils.getInstance().toObjectMap(pluginData.getConfig(), String.class);
+ String secretKey = Optional.of(configMap.get(Constants.SECRET_KEY)).orElse("");
+ String filterPath = Optional.of(configMap.get(Constants.FILTER_PATH)).orElse("");
+ JwtConfig jwtConfig = new JwtConfig();
+ jwtConfig.setSecretKey(secretKey);
+ jwtConfig.setFilterPath(Arrays.asList(StringUtils.split(filterPath, ",")));
Singleton.INST.single(JwtConfig.class, jwtConfig);
}
diff --git a/shenyu-plugin/shenyu-plugin-jwt/src/test/java/org/apache/shenyu/plugin/jwt/JwtPluginTest.java b/shenyu-plugin/shenyu-plugin-jwt/src/test/java/org/apache/shenyu/plugin/jwt/JwtPluginTest.java
index b6c2fcd..4ee4c27 100644
--- a/shenyu-plugin/shenyu-plugin-jwt/src/test/java/org/apache/shenyu/plugin/jwt/JwtPluginTest.java
+++ b/shenyu-plugin/shenyu-plugin-jwt/src/test/java/org/apache/shenyu/plugin/jwt/JwtPluginTest.java
@@ -61,7 +61,7 @@ public final class JwtPluginTest {
SpringBeanUtils springBeanUtils = SpringBeanUtils.getInstance();
springBeanUtils.setCfgContext(context);
final PluginData pluginData =
- new PluginData("pluginId", "pluginName", "{\"secretKey\":\"sinsy\",\"filterPath\":[\"/cloud/ecg/common\"]}", "0", false);
+ new PluginData("pluginId", "pluginName", "{\"secretKey\":\"sinsy\",\"filterPath\":\"/cloud/ecg/common,/cloud/ecg/selectAll\"}", "0", false);
JwtPluginDataHandler jwtPluginDataHandler = new JwtPluginDataHandler();
jwtPluginDataHandler.handlerPlugin(pluginData);
exchange = MockServerWebExchange.from(MockServerHttpRequest.get("localhost").build());
diff --git a/shenyu-plugin/shenyu-plugin-jwt/src/test/java/org/apache/shenyu/plugin/jwt/handle/JwtPluginDataHandlerTest.java b/shenyu-plugin/shenyu-plugin-jwt/src/test/java/org/apache/shenyu/plugin/jwt/handle/JwtPluginDataHandlerTest.java
index 6ee735e..fda57a7 100644
--- a/shenyu-plugin/shenyu-plugin-jwt/src/test/java/org/apache/shenyu/plugin/jwt/handle/JwtPluginDataHandlerTest.java
+++ b/shenyu-plugin/shenyu-plugin-jwt/src/test/java/org/apache/shenyu/plugin/jwt/handle/JwtPluginDataHandlerTest.java
@@ -17,6 +17,7 @@
package org.apache.shenyu.plugin.jwt.handle;
+import org.apache.commons.lang3.StringUtils;
import org.apache.shenyu.common.dto.PluginData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.utils.GsonUtils;
@@ -25,6 +26,8 @@ import org.apache.shenyu.plugin.jwt.config.JwtConfig;
import org.junit.Before;
import org.junit.Test;
+import java.util.Map;
+
import static org.junit.Assert.assertEquals;
/**
@@ -41,10 +44,12 @@ public final class JwtPluginDataHandlerTest {
@Test
public void testHandlerPlugin() {
- final PluginData pluginData = new PluginData("pluginId", "pluginName", "{\"secretKey\":\"sinsy\",\"filterPath\":[\"/cloud/ecg/common\"]}", "0", false);
+ final PluginData pluginData = new PluginData("pluginId", "pluginName", "{\"secretKey\":\"sinsy\",\"filterPath\":\"/cloud/ecg/common,/cloud/ecg/selectAll\"}", "0", false);
jwtPluginDataHandlerUnderTest.handlerPlugin(pluginData);
JwtConfig jwtConfig = Singleton.INST.get(JwtConfig.class);
- assertEquals(GsonUtils.getInstance().toJson(jwtConfig), pluginData.getConfig());
+ Map<String, String> map = GsonUtils.getInstance().toObjectMap(pluginData.getConfig(), String.class);
+ assertEquals(jwtConfig.getSecretKey(), map.get("secretKey"));
+ assertEquals(StringUtils.join(jwtConfig.getFilterPath(), ","), map.get("filterPath"));
}
@Test