Protecting Documentation Pages

There are instances where you want readers to be logged in before accessing the documentation pages. QuickieDox does not implement user authentication but provides an Auth.php page with a method canRead that returns true or false.

When REQUIRE_SIGNIN in the .env file is set to true, the Doc->read() method responsible for rendering the documentation pages calls Auth->canRead() and allows access to the page if the return value is true, otherwise the content of views/auth-required.md are displayed.

In Summary

To ensure only authenticated users can access your docs:

  1. Set REQUIRE_SIGNIN=true in the .env file.
  2. Edit Controllers/AuthController.php and Core/Auth.php and implement your authentication logic.
  3. Define appropriate routes in routes.php to handle the page interactions.
  4. Ensure the canRead() method in Auth.php returns true if a user is authenticated and false if a user is not.

Whitelisting Pages

Setting REQUIRE_SIGNIN=true in the .env file affects every markdown file that makes up your docuemntation. Meaning, any page the user tries to read will check if they are signed in. It is possible to define files that will always be accessible and excluded from this check.

# .env
...
REQUIRE_SIGNIN=true
...
// config.php
...
'whitelisted_docs'  => [
	'installation.md',
	'getting-started.md',
	'known-issues.md'
],
...

The files listed in whitelisted_docs above will always be available for reading.