Skip to content

Add option to disable password login#2318

Open
karaolidis wants to merge 1 commit into
pelican-dev:mainfrom
karaolidis:disable-password-login
Open

Add option to disable password login#2318
karaolidis wants to merge 1 commit into
pelican-dev:mainfrom
karaolidis:disable-password-login

Conversation

@karaolidis
Copy link
Copy Markdown
Contributor

This is step 1 (of many) in a series of PRs to allow Pelican Panel and https://github.com/pelican-dev/plugins/tree/main/generic-oidc-providers to be operational fully declaratively, using just external OIDC authentication.

This PR adds support to optionally hide the password log in fields.

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

The authentication system now supports disabling password-based login entirely. A new config flag controls whether users can authenticate with username and password. When disabled, the login form shows only OAuth options, hides standard login fields and actions, and rejects password authentication attempts with a user-facing message.

Changes

Password Login Disabling Feature

Layer / File(s) Summary
Configuration
config/auth.php
New disable_password_login config option sourced from AUTH_DISABLE_PASSWORD_LOGIN environment variable (defaults to false).
Core Login Logic
app/Filament/Pages/Auth/Login.php
form() conditionally renders only OAuth component when password login is disabled. getOAuthFormComponent() centers OAuth actions when password login is disabled. getFormActions() returns empty array when password login is disabled. getCredentialsFromFormData() throws ValidationException when password login is disabled.
User Messages
lang/en/auth.php
New password_login_disabled translation key provides user-facing message explaining password login is disabled and OAuth should be used instead.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add option to disable password login' directly and clearly summarizes the main change in the changeset, which adds a configuration option to disable password-based authentication.
Description check ✅ Passed The description explains the context (part of a series to enable declarative OIDC-only authentication) and states the PR adds support to optionally hide password login fields, which aligns with the changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/Filament/Pages/Auth/Login.php (1)

36-36: ⚡ Quick win

Extract repeated config check to a named helper method.

config('auth.disable_password_login', false) is called four times across different methods. A single protected helper both eliminates the repetition and makes the intent self-documenting at every call site.

♻️ Suggested refactor
+    protected function isPasswordLoginDisabled(): bool
+    {
+        return (bool) config('auth.disable_password_login', false);
+    }
+
     public function form(Schema $schema): Schema
     {
-        if (config('auth.disable_password_login', false)) {
+        if ($this->isPasswordLoginDisabled()) {
-        if (config('auth.disable_password_login', false)) {
+        if ($this->isPasswordLoginDisabled()) {
             $component->alignment(Alignment::Center);
         }
     protected function getFormActions(): array
     {
-        if (config('auth.disable_password_login', false)) {
+        if ($this->isPasswordLoginDisabled()) {
             return [];
         }
     protected function getCredentialsFromFormData(array $data): array
     {
-        if (config('auth.disable_password_login', false)) {
+        if ($this->isPasswordLoginDisabled()) {

Also applies to: 124-125, 133-133, 142-142

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/Filament/Pages/Auth/Login.php` at line 36, Extract the repeated config
check into a single protected helper on the Login Filament page: add a protected
method (e.g., isPasswordLoginDisabled()) on the App\Filament\Pages\Auth\Login
class that returns config('auth.disable_password_login', false), then replace
each direct call to config('auth.disable_password_login', false) in methods such
as render(), mount(), authenticate(), and any other usages (the occurrences
around lines referenced) with a call to this helper to remove duplication and
make intent explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@config/auth.php`:
- Line 5: The config key disable_password_login in config/auth.php reads
AUTH_DISABLE_PASSWORD_LOGIN from env but that variable is not documented in
.env.example; add a new line AUTH_DISABLE_PASSWORD_LOGIN=false (or
AUTH_DISABLE_PASSWORD_LOGIN=true if you prefer the non-default) to .env.example
with a short comment describing that it disables password-based login so new
developers and deploys see the default and purpose.

---

Nitpick comments:
In `@app/Filament/Pages/Auth/Login.php`:
- Line 36: Extract the repeated config check into a single protected helper on
the Login Filament page: add a protected method (e.g.,
isPasswordLoginDisabled()) on the App\Filament\Pages\Auth\Login class that
returns config('auth.disable_password_login', false), then replace each direct
call to config('auth.disable_password_login', false) in methods such as
render(), mount(), authenticate(), and any other usages (the occurrences around
lines referenced) with a call to this helper to remove duplication and make
intent explicit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1940a29b-1eb8-498e-b69e-a25f8e184a9a

📥 Commits

Reviewing files that changed from the base of the PR and between 4464ccb and 78de1b1.

📒 Files selected for processing (3)
  • app/Filament/Pages/Auth/Login.php
  • config/auth.php
  • lang/en/auth.php

Comment thread config/auth.php
Comment on lines +37 to +41
$components = [
$this->getOAuthFormComponent(),
];

return $schema->components($components);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified:

Suggested change
$components = [
$this->getOAuthFormComponent(),
];
return $schema->components($components);
return $schema->components([
$this->getOAuthFormComponent(),
]);

}

$actions[] = Action::make("oauth_$id")
$action = Action::make("oauth_$id")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert change (not needed)

->color($color)
->url(route('auth.oauth.redirect', ['driver' => $id], false));

$actions[] = $action;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert change (not needed)

}

return Actions::make($actions);
return $component;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure alignment() can also take a closure, so this whole return can be simplified:

Suggested change
return $component;
return Actions::make($actions)->alignment(fn () => config('auth.disable_password_login', false) ? Alignment::Center : null);

Comment on lines +133 to +137
if (config('auth.disable_password_login', false)) {
return [];
}

return parent::getFormActions();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified:

Suggested change
if (config('auth.disable_password_login', false)) {
return [];
}
return parent::getFormActions();
return config('auth.disable_password_login', false) ? [] : parent::getFormActions();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants