Add .env variable to disable basic login and WebAuthn login #3382
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
config/features.php
to disable Basic Auth (disable-basic-auth
) and WebAuthn (disable-webauthn
) through environment variables. ([config/features.phpR62-R79](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-cb496c3608c7f2c74e0a426831cf1190f53e4d332a7a681ec074325aa057bcd2R62-R79)
)AuthServiceProvider
methods (isBasicAuthEnabled
,isWebAuthnEnabled
,isOauthEnabled
) to centralize checks for enabled authentication methods. ([app/Providers/AuthServiceProvider.phpR67-R105](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-9d0a077acda375ef8f06f27e2f823037207bcbaa21c2c87cf4c113a13a3eb0c4R67-R105)
)Diagnostic and Exception Handling:
AuthDisabledCheck
, to warn if all authentication methods are disabled or improperly configured. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-47b93879767340f10bc787c89d513bfb893acd9ac426a17540f848ac44361e0eR1-R85)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-cd0f99f20efa398dce5f099ad81b1003c76a49c69b651fa8a530cd6ce6d64c66R48)
)BasicAuthDisabledExecption
andWebAuthnDisabledExecption
to handle cases where disabled authentication methods are accessed. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-01af96771b34d29e82d1a7d56c23469b0d958e1743738c4e63ebe7beaa1be190R1-R24)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-d64bd7fea443c6cc35977484df7a323cc367c153d1efcffe4d7295a01696a29dR1-R24)
)Controller Updates:
OauthController
to useAuthServiceProvider::getAvailableOauthProviders
for determining available OAuth providers. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-4fb5856344e911f5c894a3f171002426ed6b937b9fc46ba540516afe0a1b7ec9L139-R140)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-4fb5856344e911f5c894a3f171002426ed6b937b9fc46ba540516afe0a1b7ec9L169-R165)
)WebAuthnLoginController
to ensure WebAuthn is enabled before processing requests. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-9b369efd047aa28c8c56371a310edd44ce93f58720540d7aa2c7806637689959R36-R37)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-9b369efd047aa28c8c56371a310edd44ce93f58720540d7aa2c7806637689959R119-R133)
)Request and Profile Handling:
UpdateProfileRequest
andLoginRequest
to respect the disabled state of Basic Auth by modifying validation and authorization logic. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-1e5457ec606d26a6197378b5995d9af8c06336e40d2958c5f73c0a5f5a97f517R43-R48)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-0965d0e08d57a450abf45874423b7d91c620286fa36bbf5b70960c15899d2354L30-R32)
)Other Changes:
InitConfig
to include flags indicating whether Basic Auth and WebAuthn are enabled, for use in the gallery configuration. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-d31771d798b76463dc8bb0c03d41ab098b9600d38beeae4bb84cbb34c118d86fR92-R94)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3382/files#diff-d31771d798b76463dc8bb0c03d41ab098b9600d38beeae4bb84cbb34c118d86fR147-R149)
)