emqx_auth_mnesia.schema 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. %%-*- mode: erlang -*-
  2. %% emqx_auth_mnesia config mapping
  3. {mapping, "auth.mnesia.password_hash", "emqx_auth_mnesia.password_hash", [
  4. {default, sha256},
  5. {datatype, {enum, [plain, md5, sha, sha256, sha512]}}
  6. ]}.
  7. {mapping, "auth.client.$id.clientid", "emqx_auth_mnesia.clientid_list", [
  8. {datatype, string}
  9. ]}.
  10. {mapping, "auth.client.$id.password", "emqx_auth_mnesia.clientid_list", [
  11. {datatype, string}
  12. ]}.
  13. {translation, "emqx_auth_mnesia.clientid_list", fun(Conf) ->
  14. ClientList = cuttlefish_variable:filter_by_prefix("auth.client", Conf),
  15. lists:foldl(
  16. fun({["auth", "client", Id, "clientid"], ClientId}, AccIn) ->
  17. [{ClientId, cuttlefish:conf_get("auth.client." ++ Id ++ ".password", Conf)} | AccIn];
  18. (_, AccIn) ->
  19. AccIn
  20. end, [], ClientList)
  21. end}.
  22. {mapping, "auth.user.$id.username", "emqx_auth_mnesia.username_list", [
  23. {datatype, string}
  24. ]}.
  25. {mapping, "auth.user.$id.password", "emqx_auth_mnesia.username_list", [
  26. {datatype, string}
  27. ]}.
  28. {translation, "emqx_auth_mnesia.username_list", fun(Conf) ->
  29. Userlist = cuttlefish_variable:filter_by_prefix("auth.user", Conf),
  30. lists:foldl(
  31. fun({["auth", "user", Id, "username"], Username}, AccIn) ->
  32. [{Username, cuttlefish:conf_get("auth.user." ++ Id ++ ".password", Conf)} | AccIn];
  33. (_, AccIn) ->
  34. AccIn
  35. end, [], Userlist)
  36. end}.