* Initial plan * Add Google authentication with authorized email configuration Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Complete Google authentication implementation with documentation Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Fix CORS error by removing [Authorize] from auth user endpoint Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Add authorization attribute to ConfigurationController for security Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Fix JavaScript error in login button by correcting window.location.href usage Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Fix Google OAuth redirect URI configuration to resolve authentication error Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Fix OAuth state validation error by specifying authentication scheme in callback Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Fix OAuth state validation error by improving authentication configuration Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Fix authentication setup documentation with correct redirect URI Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Fix navigation buttons overlapping with authentication header Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Remove unused unsing --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> Co-authored-by: Claudio Schaad <clayschaad@users.noreply.github.com> Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
2.7 KiB
2.7 KiB
Authentication Setup Guide
Overview
The ShiftScheduler application now includes Google OAuth authentication with configurable authorized email addresses. Only users with emails listed in the configuration can access the application.
Setup Instructions
1. Create Google OAuth Application
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API
- Go to "Credentials" and create OAuth 2.0 Client IDs
- Set the authorized redirect URI to:
http://localhost:5000/signin-google(for development) - For production, use your domain:
https://yourdomain.com/signin-google
2. Configure Application
Edit Server/appsettings.json and update the authentication section:
{
"Authentication": {
"Google": {
"ClientId": "your-google-client-id.apps.googleusercontent.com",
"ClientSecret": "your-google-client-secret"
},
"AuthorizedEmails": [
"user1@gmail.com",
"user2@example.com"
]
}
}
3. For Production
For production deployment, consider using environment variables or Azure Key Vault:
Authentication__Google__ClientIdAuthentication__Google__ClientSecretAuthentication__AuthorizedEmails__0,Authentication__AuthorizedEmails__1, etc.
How It Works
Authentication Flow
- Unauthenticated users see a login screen
- Clicking "Sign in with Google" redirects to Google OAuth
- After successful Google authentication, the application checks if the user's email is in the authorized list
- Authorized users are redirected to the main application
- Unauthorized users are redirected back with an error message
API Security
- All API endpoints require authentication (
[Authorize]attribute) - Only users with emails in the
AuthorizedEmailslist can access the API - Unauthenticated requests return a 302 redirect to login
User Interface
- Login Screen: Clean, centered login form with Google sign-in button
- Authenticated Header: Shows user email and sign-out button
- Main Application: Normal shift scheduler functionality for authenticated users
Testing
To test the authentication:
- Configure Google OAuth credentials as described above
- Add your email to the
AuthorizedEmailslist - Start the application:
dotnet runfrom the Server directory - Navigate to
http://localhost:5000 - Click "Sign in with Google" and complete the OAuth flow
Security Features
- Email-based Authorization: Only specified emails can access the application
- Secure API Endpoints: All shift management APIs require authentication
- Session Management: Proper login/logout functionality
- OAuth Integration: Uses Google's secure OAuth 2.0 flow