example_login_required.adoc 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. [#example-login-required]
  2. = Example: Force Login
  3. A common use case for OliveTin with security is to expose some dashboards that require login to be able to use. This page brings together the configuration options that are needed to achieve this. The most important configuration option is setting `authRequireGuestsToLogin` to `true`.
  4. == Full example configuration
  5. ```yaml
  6. logLevel: "INFO"
  7. authRequireGuestsToLogin: true
  8. accessControlLists:
  9. - name: "admins"
  10. permissions:
  11. view: true
  12. exec: true
  13. logs: true
  14. matchUsergroups:
  15. - "admins"
  16. addToEveryAction: true
  17. authLocalUsers:
  18. enabled: true
  19. users:
  20. - username: "admin"
  21. usergroup: admins
  22. password: -- your password hash here --
  23. actions:
  24. - title: "Restart"
  25. shell: echo "Restart"
  26. dashboards:
  27. - title: "Admin Dashboard"
  28. contents:
  29. - title: "Restart"
  30. ```
  31. Note, to use this configuration, you will need to replace `-- your password hash here --` with a password hash. You can generate a password hash by looking at the options in the xref:security/local.adoc[local-users] configuration section.
  32. == Important configuration option: `authRequireGuestsToLogin`
  33. The `authRequireGuestsToLogin` option makes all guests log in before they can do anything with OliveTin. When it is enabled:
  34. * Guests (visitors who are not logged in) can only use the API to log in, log out, check that OliveTin is ready, and generate a password hash. Every other API call is refused, including starting, restarting and killing actions, and the diagnostic API calls enabled by the `insecureAllow*` options.
  35. * Guests get no permissions at all. All `defaultPermissions` are set to `false`, and ACLs never apply to guests, even an ACL that matches the `guest` username or usergroup. Such an ACL still applies to logged-in users who are in the `guest` usergroup, for example OAuth2 users given that group by `addToUsergroup`.
  36. This is stronger than setting `defaultPermissions` to `false` yourself, because with that alone an ACL that matches guests would still give them access. See the xref:upgrade/upgrade_notes.adoc#require-guests-to-login-all-api-calls[Upgrade Notes].
  37. == Per-action ACLs, vs `addToEveryAction`
  38. It is possible to specify one or more ACL per action, like so;
  39. ```yaml
  40. actions:
  41. - title: "Restart"
  42. shell: echo "Restart"
  43. acl:
  44. - name: "admins"
  45. ```
  46. However, this configuration is also a bit more verbose, and if you just have one main ACL, can save yourself some typing by using the `addToEveryAction` option in the ACL configuration.