-
-
Notifications
You must be signed in to change notification settings - Fork 125
feat: auto-login for specific use-cases #1458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: auto-login for specific use-cases #1458
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8 files reviewed, 8 comments
Additional Comments (2)
Prompt To Fix With AIThis is a comment left during a code review.
Path: backend/internal/services/auth_service.go
Line: 621:621
Comment:
Debug log statement left in production code. This will log on every token generation (every login, token refresh) and should be removed.
```suggestion
accessTokenExpiry := time.Now().Add(time.Duration(sessionTimeout) * time.Minute)
```
How can I resolve this? If you propose a fix, please make it concise.
Consider clearing this key on logout to ensure auto-login status is re-checked after logging back in: logout(): void {
this.clearTokenData();
userStore.clearUser();
try {
sessionStorage.removeItem('arcane_auto_login_disabled');
} catch {
// Ignore storage errors
}
}Prompt To Fix With AIThis is a comment left during a code review.
Path: frontend/src/lib/services/auth-service.ts
Line: 195:198
Comment:
The `logout()` method doesn't clear the `AUTO_LOGIN_DISABLED_KEY` from sessionStorage. This means if auto-login is disabled on first load but then gets enabled later (e.g., in a dev/test environment), the frontend will continue to skip auto-login checks until the session storage is manually cleared or the browser is restarted.
Consider clearing this key on logout to ensure auto-login status is re-checked after logging back in:
```typescript
logout(): void {
this.clearTokenData();
userStore.clearUser();
try {
sessionStorage.removeItem('arcane_auto_login_disabled');
} catch {
// Ignore storage errors
}
}
```
How can I resolve this? If you propose a fix, please make it concise. |
Created auto-login-store to avoid to many props drilldown
kmendell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few things ive noticed off the bat, i dont have time to fully review but this should give you a starting point.
| Tags: []string{"Auth"}, | ||
| }, h.GetAutoLoginConfig) | ||
|
|
||
| huma.Register(api, huma.Operation{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to use the existing auth/login endpoint for this no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could but I think it is better to isolate the auto-login logic from the login one to avoid any side effect or complexity on the login logic.
As you prefer, I can refactor to include the logic in the login func handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I more over meant for the actual login, as its does the same thing i would assume, just should post with the given variables? Instead of the ones passed via the form
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to commit and push on this to move forward 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
18 files reviewed, 1 comment
|
This pull request has merge conflicts. Please resolve the conflicts so the PR can stay up-to-date and reviewed. |
|
I will continue reviewing this soon. Probably for 1.14.0 |
|
This pull request has merge conflicts. Please resolve the conflicts so the PR can stay up-to-date and reviewed. |
|
This pull request has merge conflicts. Please resolve the conflicts so the PR can stay up-to-date and reviewed. |
|
This pull request has merge conflicts. Please resolve the conflicts so the PR can stay up-to-date and reviewed. |
|
Ive been thinking about this more and the risk is just too high for my liking to stick with just env variables to enable this. So my thinking is this:
This would require whoever would wnat to use this feature build a custom image in order to enable it therefore requiring alot more work for an attacker if that were the case. |
Clearly this is more secure, you can also build another image with a tag prefix "auto-login-*". Could be a good use-case for Golang build tag (Build constraint) to have the API version with auto-login or not at build time. |
|
Good point build tags may work too. However my main thing is i wouldnt publish the images, then theres no "safeguard" if an attacker would wnat to try they would have to go through more work by building there own thing, is where im coming from. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
This pull request has merge conflicts. Please resolve the conflicts so the PR can stay up-to-date and reviewed. |
|
@Nightbr Well that's annoying... can you reopen this against main for me please? |
resolves #653
🚀 Auto-Login Feature Summary
What's New
🔐 Auto-Login Configuration - New environment variables to enable automatic authentication:
AUTO_LOGIN_ENABLE- Enable/disable auto-login (default:false)AUTO_LOGIN_USERNAME- Username for auto-login (default:arcane)🌐 New API Endpoints:
GET /api/auth/auto-login-config- Returns auto-login status and username (never exposes password)POST /api/auth/auto-login- Performs authentication using server-configured credentials🖥️ Frontend Auto-Login Flow - Automatically logs in users when:
🔓 Password Change Dialog Skipped - When auto-login is enabled, the "change password" dialog is automatically bypassed
🧪 Testing Guide
1. Configure Environment Variables
Add the following to your
.envfile ordocker/compose.dev.yaml:64:2. Start the dev env
3. Verify Backend Configuration
Test that the backend returns the correct config:
Expected response:
{ "success": true, "data": { "enabled": true, "username": "arcane" } }4. Test Auto-Login Endpoint
Expected response:
{ "success": true, "data": { "token": "eyJ...", "refreshToken": "eyJ...", "expiresAt": "...", "user": { "id": "...", "username": "arcane", "displayName": "Arcane Admin", ... } } }5. Test Frontend Auto-Login
arcane_auto_login_disabledkey if presenthttp://localhost:30006. Test Disabled State
Set
AUTO_LOGIN_ENABLE=falseand restart:Expected:
{ "success": true, "data": { "enabled": false, "username": "" } }7. Test Auto-Login After Logout
Disclaimer Greptiles Reviews use AI, make sure to check over its work
Greptile Summary
Adds auto-login functionality for development and testing environments, allowing users to bypass the login screen when configured via environment variables.
Key Changes:
AUTO_LOGIN_ENABLE,AUTO_LOGIN_USERNAME, andAUTO_LOGIN_PASSWORDenvironment variablesGET /api/auth/auto-login-config(returns enabled status and username) andPOST /api/auth/auto-login(performs authentication)Security Considerations:
AutoLoginPasswordfield hasoptions:"file"tag for proper masking in logsConfidence Score: 4/5
Important Files Changed