|
|
@@ -55,8 +55,8 @@
|
|
|
listener_authenticators/2,
|
|
|
listener_authenticator/2,
|
|
|
listener_authenticator_status/2,
|
|
|
- authenticator_move/2,
|
|
|
- listener_authenticator_move/2,
|
|
|
+ authenticator_position/2,
|
|
|
+ listener_authenticator_position/2,
|
|
|
authenticator_users/2,
|
|
|
authenticator_user/2,
|
|
|
listener_authenticator_users/2,
|
|
|
@@ -67,7 +67,6 @@
|
|
|
|
|
|
-export([
|
|
|
authenticator_examples/0,
|
|
|
- request_move_examples/0,
|
|
|
request_user_create_examples/0,
|
|
|
request_user_update_examples/0,
|
|
|
response_user_examples/0,
|
|
|
@@ -99,14 +98,14 @@ paths() ->
|
|
|
"/authentication",
|
|
|
"/authentication/:id",
|
|
|
"/authentication/:id/status",
|
|
|
- "/authentication/:id/move",
|
|
|
+ "/authentication/:id/position/:position",
|
|
|
"/authentication/:id/users",
|
|
|
"/authentication/:id/users/:user_id",
|
|
|
|
|
|
"/listeners/:listener_id/authentication",
|
|
|
"/listeners/:listener_id/authentication/:id",
|
|
|
"/listeners/:listener_id/authentication/:id/status",
|
|
|
- "/listeners/:listener_id/authentication/:id/move",
|
|
|
+ "/listeners/:listener_id/authentication/:id/position/:position",
|
|
|
"/listeners/:listener_id/authentication/:id/users",
|
|
|
"/listeners/:listener_id/authentication/:id/users/:user_id"
|
|
|
].
|
|
|
@@ -115,7 +114,6 @@ roots() ->
|
|
|
[
|
|
|
request_user_create,
|
|
|
request_user_update,
|
|
|
- request_move,
|
|
|
response_user,
|
|
|
response_users
|
|
|
].
|
|
|
@@ -130,8 +128,6 @@ fields(request_user_update) ->
|
|
|
{password, mk(binary(), #{required => true})},
|
|
|
{is_superuser, mk(boolean(), #{default => false, required => false})}
|
|
|
];
|
|
|
-fields(request_move) ->
|
|
|
- [{position, mk(binary(), #{required => true})}];
|
|
|
fields(response_user) ->
|
|
|
[
|
|
|
{user_id, mk(binary(), #{required => true})},
|
|
|
@@ -321,17 +317,13 @@ schema("/listeners/:listener_id/authentication/:id/status") ->
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
-schema("/authentication/:id/move") ->
|
|
|
+schema("/authentication/:id/position/:position") ->
|
|
|
#{
|
|
|
- 'operationId' => authenticator_move,
|
|
|
- post => #{
|
|
|
+ 'operationId' => authenticator_position,
|
|
|
+ put => #{
|
|
|
tags => ?API_TAGS_GLOBAL,
|
|
|
- description => ?DESC(authentication_id_move_post),
|
|
|
- parameters => [param_auth_id()],
|
|
|
- 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
|
|
- ref(request_move),
|
|
|
- request_move_examples()
|
|
|
- ),
|
|
|
+ description => ?DESC(authentication_id_position_put),
|
|
|
+ parameters => [param_auth_id(), param_position()],
|
|
|
responses => #{
|
|
|
204 => <<"Authenticator moved">>,
|
|
|
400 => error_codes([?BAD_REQUEST], <<"Bad Request">>),
|
|
|
@@ -339,17 +331,13 @@ schema("/authentication/:id/move") ->
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
-schema("/listeners/:listener_id/authentication/:id/move") ->
|
|
|
+schema("/listeners/:listener_id/authentication/:id/position/:position") ->
|
|
|
#{
|
|
|
- 'operationId' => listener_authenticator_move,
|
|
|
- post => #{
|
|
|
+ 'operationId' => listener_authenticator_position,
|
|
|
+ put => #{
|
|
|
tags => ?API_TAGS_SINGLE,
|
|
|
- description => ?DESC(listeners_listener_id_authentication_id_move_post),
|
|
|
- parameters => [param_listener_id(), param_auth_id()],
|
|
|
- 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
|
|
- ref(request_move),
|
|
|
- request_move_examples()
|
|
|
- ),
|
|
|
+ description => ?DESC(listeners_listener_id_authentication_id_position_put),
|
|
|
+ parameters => [param_listener_id(), param_auth_id(), param_position()],
|
|
|
responses => #{
|
|
|
204 => <<"Authenticator moved">>,
|
|
|
400 => error_codes([?BAD_REQUEST], <<"Bad Request">>),
|
|
|
@@ -556,6 +544,17 @@ param_listener_id() ->
|
|
|
})
|
|
|
}.
|
|
|
|
|
|
+param_position() ->
|
|
|
+ {
|
|
|
+ position,
|
|
|
+ mk(binary(), #{
|
|
|
+ in => path,
|
|
|
+ desc => ?DESC(param_position),
|
|
|
+ required => true,
|
|
|
+ example => "before:password_based:built_in_database"
|
|
|
+ })
|
|
|
+ }.
|
|
|
+
|
|
|
param_user_id() ->
|
|
|
{
|
|
|
user_id,
|
|
|
@@ -662,23 +661,15 @@ listener_authenticator_status(
|
|
|
end
|
|
|
).
|
|
|
|
|
|
-authenticator_move(
|
|
|
- post,
|
|
|
- #{
|
|
|
- bindings := #{id := AuthenticatorID},
|
|
|
- body := #{<<"position">> := Position}
|
|
|
- }
|
|
|
+authenticator_position(
|
|
|
+ put,
|
|
|
+ #{bindings := #{id := AuthenticatorID, position := Position}}
|
|
|
) ->
|
|
|
- move_authenticator([authentication], ?GLOBAL, AuthenticatorID, Position);
|
|
|
-authenticator_move(post, #{bindings := #{id := _}, body := _}) ->
|
|
|
- serialize_error({missing_parameter, position}).
|
|
|
+ move_authenticator([authentication], ?GLOBAL, AuthenticatorID, Position).
|
|
|
|
|
|
-listener_authenticator_move(
|
|
|
- post,
|
|
|
- #{
|
|
|
- bindings := #{listener_id := ListenerID, id := AuthenticatorID},
|
|
|
- body := #{<<"position">> := Position}
|
|
|
- }
|
|
|
+listener_authenticator_position(
|
|
|
+ put,
|
|
|
+ #{bindings := #{listener_id := ListenerID, id := AuthenticatorID, position := Position}}
|
|
|
) ->
|
|
|
with_listener(
|
|
|
ListenerID,
|
|
|
@@ -690,9 +681,7 @@ listener_authenticator_move(
|
|
|
Position
|
|
|
)
|
|
|
end
|
|
|
- );
|
|
|
-listener_authenticator_move(post, #{bindings := #{listener_id := _, id := _}, body := _}) ->
|
|
|
- serialize_error({missing_parameter, position}).
|
|
|
+ ).
|
|
|
|
|
|
authenticator_users(post, #{bindings := #{id := AuthenticatorID}, body := UserInfo}) ->
|
|
|
add_user(?GLOBAL, AuthenticatorID, UserInfo);
|
|
|
@@ -1475,28 +1464,6 @@ request_user_update_examples() ->
|
|
|
}
|
|
|
}.
|
|
|
|
|
|
-request_move_examples() ->
|
|
|
- #{
|
|
|
- move_to_front => #{
|
|
|
- summary => <<"Move authenticator to the beginning of the chain">>,
|
|
|
- value => #{
|
|
|
- position => <<"front">>
|
|
|
- }
|
|
|
- },
|
|
|
- move_to_rear => #{
|
|
|
- summary => <<"Move authenticator to the end of the chain">>,
|
|
|
- value => #{
|
|
|
- position => <<"rear">>
|
|
|
- }
|
|
|
- },
|
|
|
- 'move_before_password_based:built_in_database' => #{
|
|
|
- summary => <<"Move authenticator to the position preceding some other authenticator">>,
|
|
|
- value => #{
|
|
|
- position => <<"before:password_based:built_in_database">>
|
|
|
- }
|
|
|
- }
|
|
|
- }.
|
|
|
-
|
|
|
response_user_examples() ->
|
|
|
#{
|
|
|
regular_user => #{
|