-
Notifications
You must be signed in to change notification settings - Fork 20
Fix configuration persistence and dashboard authentication issues #13
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { NextResponse } from 'next/server'; | ||
| import { configLoader } from '@/lib/config/configLoader'; | ||
|
|
||
| export async function GET() { | ||
| try { | ||
| // Load config to check if password is set | ||
| const config = await configLoader.loadConfig(); | ||
| const dashboardPassword = config.global?.server?.dashboardPassword; | ||
|
|
||
| return NextResponse.json({ | ||
| passwordRequired: !!dashboardPassword && dashboardPassword.length > 0, | ||
| }); | ||
| } catch (error) { | ||
| console.error('Failed to check auth status:', error); | ||
| return NextResponse.json({ passwordRequired: false }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | |||||||||||||||||||||||||||||
| 'use client'; | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| import { useEffect } from 'react'; | |||||||||||||||||||||||||||||
| import { useRouter } from 'next/navigation'; | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| export function AuthCheck() { | |||||||||||||||||||||||||||||
| const router = useRouter(); | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| useEffect(() => { | |||||||||||||||||||||||||||||
| const checkAuth = async () => { | |||||||||||||||||||||||||||||
| try { | |||||||||||||||||||||||||||||
| // Check if password is required | |||||||||||||||||||||||||||||
| const response = await fetch('/api/auth/check'); | |||||||||||||||||||||||||||||
| const data = await response.json(); | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| // Set cookie to indicate if password is required | |||||||||||||||||||||||||||||
| if (data.passwordRequired) { | |||||||||||||||||||||||||||||
| document.cookie = 'password-required=true; path=/; max-age=86400'; // 24 hours | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| // Check if we have a valid auth token | |||||||||||||||||||||||||||||
| const authToken = document.cookie | |||||||||||||||||||||||||||||
| .split('; ') | |||||||||||||||||||||||||||||
| .find(row => row.startsWith('auth-token=')); | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| if (!authToken) { | |||||||||||||||||||||||||||||
| // No auth token, redirect to login | |||||||||||||||||||||||||||||
| router.push('/login?redirect=' + encodeURIComponent(window.location.pathname)); | |||||||||||||||||||||||||||||
| } | |||||||||||||||||||||||||||||
| } else { | |||||||||||||||||||||||||||||
| // No password required, clear the cookie | |||||||||||||||||||||||||||||
| document.cookie = 'password-required=false; path=/; max-age=86400'; | |||||||||||||||||||||||||||||
Check warningCode scanning / CodeQL Clear text transmission of sensitive cookie Medium
Sensitive cookie sent without enforcing SSL encryption.
Copilot AutofixAI 5 months ago To fix the problem, we should append
Suggested changeset
1
src/components/AuthCheck.tsx
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||||||||
| } | |||||||||||||||||||||||||||||
| } catch (error) { | |||||||||||||||||||||||||||||
| console.error('Failed to check auth status:', error); | |||||||||||||||||||||||||||||
| } | |||||||||||||||||||||||||||||
| }; | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| checkAuth(); | |||||||||||||||||||||||||||||
| }, [router]); | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| return null; // This component doesn't render anything | |||||||||||||||||||||||||||||
| } | |||||||||||||||||||||||||||||
Check warning
Code scanning / CodeQL
Clear text transmission of sensitive cookie Medium
Copilot Autofix
AI 5 months ago
To fix the problem, we need to ensure that any sensitive cookies set in the code, like
password-required, include thesecureattribute so they are only sent over HTTPS connections. Specifically, insrc/components/AuthCheck.tsx, two places set or update thepassword-requiredcookie (lines 18 and 31). We should add the string; secureto the cookie value in both cases. This change can be safely made by appending; secureto the cookie string in both assignments todocument.cookie. No new imports or methods are needed.