Lychee icon indicating copy to clipboard operation
Lychee copied to clipboard

Add .env variable to disable basic login and WebAuthn login

Open ildyria opened this issue 7 months ago • 1 comments

Additionally, add a automatic redirection to the oauth url if that is the only login option available.

This pull request introduces support for disabling specific authentication methods (Basic Auth and WebAuthn) via configuration, along with adjustments to ensure proper handling when these methods are disabled. The changes include new diagnostic checks, exception handling, and updates to controllers and requests to respect the configuration settings.

Authentication Configuration Enhancements:

  • Added new configuration options in config/features.php to disable Basic Auth (disable-basic-auth) and WebAuthn (disable-webauthn) through environment variables. ([config/features.phpR62-R79](diffhunk://#diff-cb496c3608c7f2c74e0a426831cf1190f53e4d332a7a681ec074325aa057bcd2R62-R79))
  • Introduced AuthServiceProvider methods (isBasicAuthEnabled, isWebAuthnEnabled, isOauthEnabled) to centralize checks for enabled authentication methods. ([app/Providers/AuthServiceProvider.phpR67-R105](diffhunk://#diff-9d0a077acda375ef8f06f27e2f823037207bcbaa21c2c87cf4c113a13a3eb0c4R67-R105))

Diagnostic and Exception Handling:

  • Added a new diagnostic check, AuthDisabledCheck, to warn if all authentication methods are disabled or improperly configured. ([[1]](diffhunk://#diff-47b93879767340f10bc787c89d513bfb893acd9ac426a17540f848ac44361e0eR1-R85), [[2]](diffhunk://#diff-cd0f99f20efa398dce5f099ad81b1003c76a49c69b651fa8a530cd6ce6d64c66R48))
  • Introduced BasicAuthDisabledExecption and WebAuthnDisabledExecption to handle cases where disabled authentication methods are accessed. ([[1]](diffhunk://#diff-01af96771b34d29e82d1a7d56c23469b0d958e1743738c4e63ebe7beaa1be190R1-R24), [[2]](diffhunk://#diff-d64bd7fea443c6cc35977484df7a323cc367c153d1efcffe4d7295a01696a29dR1-R24))

Controller Updates:

  • Updated OauthController to use AuthServiceProvider::getAvailableOauthProviders for determining available OAuth providers. ([[1]](diffhunk://#diff-4fb5856344e911f5c894a3f171002426ed6b937b9fc46ba540516afe0a1b7ec9L139-R140), [[2]](diffhunk://#diff-4fb5856344e911f5c894a3f171002426ed6b937b9fc46ba540516afe0a1b7ec9L169-R165))
  • Added validation in WebAuthnLoginController to ensure WebAuthn is enabled before processing requests. ([[1]](diffhunk://#diff-9b369efd047aa28c8c56371a310edd44ce93f58720540d7aa2c7806637689959R36-R37), [[2]](diffhunk://#diff-9b369efd047aa28c8c56371a310edd44ce93f58720540d7aa2c7806637689959R119-R133))

Request and Profile Handling:

  • Adjusted UpdateProfileRequest and LoginRequest to respect the disabled state of Basic Auth by modifying validation and authorization logic. ([[1]](diffhunk://#diff-1e5457ec606d26a6197378b5995d9af8c06336e40d2958c5f73c0a5f5a97f517R43-R48), [[2]](diffhunk://#diff-0965d0e08d57a450abf45874423b7d91c620286fa36bbf5b70960c15899d2354L30-R32))

Other Changes:

  • Updated InitConfig to include flags indicating whether Basic Auth and WebAuthn are enabled, for use in the gallery configuration. ([[1]](diffhunk://#diff-d31771d798b76463dc8bb0c03d41ab098b9600d38beeae4bb84cbb34c118d86fR92-R94), [[2]](diffhunk://#diff-d31771d798b76463dc8bb0c03d41ab098b9600d38beeae4bb84cbb34c118d86fR147-R149))

ildyria avatar May 29 '25 15:05 ildyria

Codecov Report

:x: Patch coverage is 54.54545% with 25 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 90.60%. Comparing base (93a2101) to head (6d3c2d1). :warning: Report is 9 commits behind head on master.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 29 '25 15:05 codecov[bot]