Skip to content

7 add admin authentication#16

Merged
MicRaj merged 8 commits into
mainfrom
7-add-admin-authentication
Sep 6, 2025
Merged

7 add admin authentication#16
MicRaj merged 8 commits into
mainfrom
7-add-admin-authentication

Conversation

@MicRaj

@MicRaj MicRaj commented Sep 6, 2025

Copy link
Copy Markdown
Owner

No description provided.

@MicRaj MicRaj linked an issue Sep 6, 2025 that may be closed by this pull request
- Implement HTML sanitization in post creation
- Add user ID association to blog posts
- Update user creation to enforce admin role check
- Modify post retrieval endpoints to use slug and ID
- Improve post deletion and update authorization checks
- Add is_admin field to User model
- Update initial admin creation to set is_admin to True
- Update PostGrid component styles for better UX
- Refactor post detail page for improved layout and content rendering
@MicRaj MicRaj requested a review from Copilot September 6, 2025 13:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements admin authentication functionality for the blog application, including user management, session-based authentication, and secure access controls for the post editor and API endpoints.

  • Adds user authentication system with login/logout functionality and session management
  • Implements admin-only access controls for post creation, editing, and deletion
  • Updates API endpoints to use proper authentication and authorization
  • Migrates backend from port 8000 to 3000 and adds Docker secrets for secure credential management

Reviewed Changes

Copilot reviewed 18 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
nginx/nginx.conf Updates proxy configuration to forward requests to backend on port 3000
frontend/src/routes/posts/[slug]/+page.svelte Updates API endpoint and improves post display with HTML rendering
frontend/src/routes/post-editor/+page.svelte Adds user authentication check and welcome message
frontend/src/routes/post-editor/+page.server.ts Implements server-side authentication validation for post editor access
frontend/src/routes/old/+page.svelte Removes old page implementation
frontend/src/routes/login/+page.svelte Adds login form component with authentication handling
frontend/src/routes/login/+page.server.ts Implements login page server-side logic
frontend/src/routes/+page.svelte Removes unused CSS and code cleanup
frontend/src/lib/components/PostGrid.svelte Adds styling for post card links
docker-compose.yml Adds Docker secrets and environment variables for secure authentication
backend/app/models/user.py Defines user model with authentication fields
backend/app/models/session.py Implements session management model
backend/app/models/blog_post.py Adds user_id foreign key to blog posts
backend/app/main.py Updates main application with authentication routers and production mode
backend/app/core/db_init.py Implements initial admin user creation
backend/app/api/users.py Adds user management and authentication endpoints
backend/app/api/posts.py Updates post endpoints with authentication and HTML sanitization
backend/Dockerfile Updates backend to run on port 3000

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread backend/app/core/db_init.py Outdated
ADMIN_USERNAME = os.getenv("ADMIN_USERNAME")
secret_file = Path("/run/secrets/admin_password")
ADMIN_PASSWORD = secret_file.read_text().strip()
print(f"ADMIN_USERNAME: {ADMIN_USERNAME}, ADMIN_PASSWORD: {ADMIN_PASSWORD}")

Copilot AI Sep 6, 2025

Copy link

Choose a reason for hiding this comment

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

Logging the admin password in plain text is a security risk. Remove or mask the password from the log output.

Suggested change
print(f"ADMIN_USERNAME: {ADMIN_USERNAME}, ADMIN_PASSWORD: {ADMIN_PASSWORD}")
print(f"ADMIN_USERNAME: {ADMIN_USERNAME}")

Copilot uses AI. Check for mistakes.
@MicRaj MicRaj marked this pull request as draft September 6, 2025 13:36
@MicRaj MicRaj marked this pull request as ready for review September 6, 2025 13:36
@MicRaj MicRaj merged commit f60e50e into main Sep 6, 2025
2 checks passed
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.

Add authentication

2 participants