|
1 | | -CREATE PROCEDURE teleport_activate_user(IN username VARCHAR(80), IN details JSON) |
| 1 | +CREATE PROCEDURE teleport_activate_user(IN username TEXT, IN details JSON) |
2 | 2 | proc_label:BEGIN |
3 | 3 | DECLARE is_auto_user INT DEFAULT 0; |
4 | 4 | DECLARE is_active INT DEFAULT 0; |
5 | 5 | DECLARE is_same_user INT DEFAULT 0; |
6 | 6 | DECLARE role_index INT DEFAULT 0; |
7 | | - DECLARE cur_role VARCHAR(128) DEFAULT ''; |
| 7 | + DECLARE cur_role TEXT DEFAULT ''; |
8 | 8 | DECLARE cur_roles TEXT DEFAULT ''; |
9 | 9 | SET @roles = JSON_EXTRACT(details, "$.roles"); |
10 | 10 | SET @teleport_user = JSON_VALUE(details, "$.attributes.user"); |
@@ -72,11 +72,10 @@ proc_label:BEGIN |
72 | 72 | CALL teleport_revoke_roles(username); |
73 | 73 | SET role_index = 0; |
74 | 74 | WHILE role_index < JSON_LENGTH(@roles) DO |
75 | | - SELECT JSON_EXTRACT(@roles, CONCAT('$[',role_index,']')) INTO cur_role; |
| 75 | + SELECT JSON_UNQUOTE(JSON_EXTRACT(@roles, CONCAT('$[',role_index,']'))) INTO cur_role; |
76 | 76 | SELECT role_index + 1 INTO role_index; |
77 | 77 |
|
78 | | - -- role extracted from JSON already has double quotes. |
79 | | - SET @sql := CONCAT_WS(' ', 'GRANT', cur_role, 'TO', QUOTE(@all_in_one_role)); |
| 78 | + SET @sql := CONCAT_WS(' ', 'GRANT', QUOTE(cur_role), 'TO', QUOTE(@all_in_one_role)); |
80 | 79 | PREPARE stmt FROM @sql; |
81 | 80 | EXECUTE stmt; |
82 | 81 | DEALLOCATE PREPARE stmt; |
|
0 commit comments