-
Notifications
You must be signed in to change notification settings - Fork 8
Implement comprehensive authentication system with modular architecture #35
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
Draft
rnavyaprabha
wants to merge
9
commits into
mieweb:main
Choose a base branch
from
rnavyaprabha:Authentication
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7a8f675
Implement comprehensive authentication system with modular architecture
rnavyaprabha 9ca9200
Merge remote-tracking branch 'origin/main' into Authentication
rnavyaprabha 2890a63
feat: Enable password complexity validation and UI feedback
rnavyaprabha b438004
Removing test cases
rnavyaprabha 77ff844
feat: Implement email-based authentication with Meteor's built-in fea…
rnavyaprabha 1c7e744
fix: Implement case-insensitive email validation and uniqueness
rnavyaprabha fcc2392
feat: Add Google OAuth login and signup
rnavyaprabha d3f7837
refactor: Replace custom Google OAuth with Meteor's built-in loginWit…
rnavyaprabha 6444cdc
security: Remove settings.json from git tracking
rnavyaprabha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| node_modules/ | ||
| .DS_Store | ||
| .DS_Store | ||
| settings.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| # Authentication System Improvements | ||
|
|
||
| ## Overview | ||
| This PR introduces a comprehensive improvement to the authentication system, addressing security concerns and enhancing user experience through proper validation, modular code organization, and modern UI/UX patterns. | ||
|
|
||
| ## 🚀 Key Improvements | ||
|
|
||
| ### 1. **Enhanced Security** | ||
| - **Password Complexity Requirements**: Minimum 8 characters with uppercase, lowercase, numbers, and special characters | ||
| - **Username Validation**: 3-20 characters, alphanumeric with underscores/hyphens only | ||
| - **Rate Limiting**: Prevents brute force attacks (5 attempts per 15 minutes, 30-minute lockout) | ||
| - **Weak Password Detection**: Blocks common weak passwords like "password", "123456", etc. | ||
| - **Reserved Username Protection**: Prevents use of reserved words like "admin", "root", etc. | ||
|
|
||
| ### 2. **Real-time Validation** | ||
| - **Live Username Availability Check**: Debounced server-side validation | ||
| - **Password Strength Indicator**: Visual feedback with color-coded strength bars | ||
| - **Real-time Requirements Checklist**: Shows which password requirements are met | ||
| - **Form Validation**: Prevents submission until all requirements are met | ||
|
|
||
| ### 3. **Improved User Experience** | ||
| - **Modern UI Design**: Clean, responsive interface with proper spacing and typography | ||
| - **Loading States**: Visual feedback during authentication operations | ||
| - **Error Handling**: Specific, user-friendly error messages | ||
| - **Success Feedback**: Clear confirmation of successful operations | ||
| - **Forgot Password Feature**: Complete password reset functionality | ||
|
|
||
| ### 4. **Code Organization** | ||
| - **Modular Structure**: Separated authentication logic into dedicated files | ||
| - **Reusable Components**: Validation utilities that can be used elsewhere | ||
| - **Clean Separation**: Client-side validation, server-side validation, and UI logic | ||
| - **Maintainable Code**: Easy to extend and modify | ||
|
|
||
| ## 📁 File Structure | ||
|
|
||
| ``` | ||
| client/ | ||
| ├── components/ | ||
| │ └── auth/ | ||
| │ ├── authValidation.js # Client-side validation utilities | ||
| │ ├── authTemplates.html # Authentication UI templates | ||
| │ └── authLogic.js # Client-side authentication logic | ||
| server/ | ||
| ├── auth.js # Server-side authentication methods | ||
| └── main.js # Updated to use new auth methods | ||
| ``` | ||
|
|
||
| ## 🔧 Technical Details | ||
|
|
||
| ### Validation Rules | ||
|
|
||
| #### Username Requirements: | ||
| - Minimum: 3 characters | ||
| - Maximum: 20 characters | ||
| - Allowed characters: letters, numbers, underscores, hyphens | ||
| - Reserved words blocked: admin, root, system, user, test, guest, administrator | ||
|
|
||
| #### Password Requirements: | ||
| - Minimum: 8 characters | ||
| - Maximum: 128 characters | ||
| - Must contain: uppercase, lowercase, number, special character | ||
| - Weak passwords blocked: password, 123456, qwerty, admin, letmein, etc. | ||
|
|
||
| ### Security Features | ||
|
|
||
| #### Rate Limiting: | ||
| - **Login Attempts**: 5 attempts per 15-minute window | ||
| - **Signup Attempts**: 5 attempts per 15-minute window | ||
| - **Password Reset**: 5 attempts per 15-minute window | ||
| - **Lockout Duration**: 30 minutes after exceeding limit | ||
|
|
||
| #### Error Handling: | ||
| - Generic error messages for security (doesn't reveal if user exists) | ||
| - Specific validation errors for user guidance | ||
| - Proper error logging for debugging | ||
|
|
||
| ## 🎯 Benefits | ||
|
|
||
| ### For Users: | ||
| - **Clear Guidance**: Real-time feedback on what's required | ||
| - **Better Security**: Stronger passwords protect their accounts | ||
| - **Improved UX**: Modern interface with proper loading states | ||
| - **Password Recovery**: Forgot password functionality | ||
|
|
||
| ### For Developers: | ||
| - **Maintainable Code**: Modular structure makes it easy to modify | ||
| - **Reusable Components**: Validation utilities can be used elsewhere | ||
| - **Better Testing**: Separated concerns make testing easier | ||
| - **Scalable**: Easy to add new authentication features | ||
|
|
||
| ### For Security: | ||
| - **Brute Force Protection**: Rate limiting prevents attacks | ||
| - **Strong Passwords**: Complexity requirements improve security | ||
| - **Input Validation**: Server-side validation prevents malicious input | ||
| - **Error Handling**: Doesn't leak sensitive information | ||
|
|
||
| ## 🧪 Testing | ||
|
|
||
| ### Manual Testing Scenarios: | ||
| 1. **Valid Signup**: Create account with strong password | ||
| 2. **Weak Password**: Try to use "password" or "123456" | ||
| 3. **Invalid Username**: Try special characters or reserved words | ||
| 4. **Duplicate Username**: Try to create account with existing username | ||
| 5. **Rate Limiting**: Try multiple failed login attempts | ||
| 6. **Password Reset**: Use forgot password functionality | ||
| 7. **Real-time Validation**: Type in forms and see live feedback | ||
|
|
||
| ### Expected Behaviors: | ||
| - ✅ Strong passwords are accepted | ||
| - ❌ Weak passwords are rejected with specific error | ||
| - ✅ Available usernames show green checkmark | ||
| - ❌ Taken usernames show error message | ||
| - ✅ Form only submits when all validations pass | ||
| - ❌ Rate limiting blocks excessive attempts | ||
| - ✅ Password strength indicator shows appropriate level | ||
|
|
||
| ## 🔄 Migration Notes | ||
|
|
||
| ### Breaking Changes: | ||
| - **Password Requirements**: Existing users with weak passwords may need to update them | ||
| - **Username Requirements**: Some existing usernames might not meet new requirements | ||
|
|
||
| ### Backward Compatibility: | ||
| - Existing accounts continue to work | ||
| - Old authentication methods are replaced but functionality is preserved | ||
| - No data migration required | ||
|
|
||
| ## 📈 Future Enhancements | ||
|
|
||
| ### Potential Additions: | ||
| - **Email Verification**: Require email verification for new accounts | ||
| - **Two-Factor Authentication**: Add 2FA support | ||
| - **Social Login**: Google, GitHub, etc. integration | ||
| - **Password History**: Prevent reuse of recent passwords | ||
| - **Account Lockout**: Lock accounts after suspicious activity | ||
| - **Audit Logging**: Track authentication events | ||
|
|
||
| ### Code Improvements: | ||
| - **Unit Tests**: Add comprehensive test coverage | ||
| - **Integration Tests**: Test full authentication flow | ||
| - **Performance**: Optimize validation performance | ||
| - **Accessibility**: Improve screen reader support | ||
|
|
||
| ## 🎉 Conclusion | ||
|
|
||
| This authentication improvement significantly enhances the security and user experience of the TimeHarbor application. The modular code structure makes it easy to maintain and extend, while the comprehensive validation ensures data integrity and user account security. | ||
|
|
||
| The improvements follow modern web development best practices and provide a solid foundation for future authentication features. |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is good. If it’s accurate. I saw your video. Is the steps accurate?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A link to your video would be good. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Google OAuth Setup Guide | ||
|
|
||
| ## Prerequisites | ||
| - A Google account | ||
| - Access to Google Cloud Console | ||
|
|
||
| ## Step 1: Create Google Cloud Project | ||
|
|
||
| 1. Go to [Google Cloud Console](https://console.cloud.google.com/) | ||
| 2. Create a new project or select an existing one | ||
| 3. Enable the Google+ API (or Google Identity API) | ||
|
|
||
| ## Step 2: Create a settings.json file | ||
|
|
||
| Create a file called `settings.json` in your project root with your credentials: | ||
|
|
||
| ```json | ||
| { | ||
| "google": { | ||
| "clientId": "your_actual_client_id_here", | ||
| "clientSecret": "your_actual_client_secret_here" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Step 3: Start your app with settings | ||
|
|
||
| Run your Meteor app with the settings file: | ||
|
|
||
| ## Step 4: Get Your Credentials | ||
|
|
||
| After creating the OAuth client, you'll get: | ||
| - **Client ID**: A long string ending with `.apps.googleusercontent.com` | ||
| - **Client Secret**: A secret string | ||
|
|
||
| ## Step 5: Configure Environment Variables | ||
|
|
||
| Create a `.env` file in your project root with: | ||
|
|
||
| ```bash | ||
| GOOGLE_CLIENT_ID=your_client_id_here | ||
| GOOGLE_CLIENT_SECRET=your_client_secret_here | ||
| ``` | ||
|
|
||
| ## Step 6: Install Environment Variables Package | ||
|
|
||
| ```bash | ||
| meteor add dotenv | ||
| ``` | ||
|
|
||
| ## Step 7: Test the Setup | ||
|
|
||
| 1. Start your Meteor app: `meteor run` | ||
| 2. Go to the login/signup page | ||
| 3. Click "Continue with Google" | ||
| 4. You should be redirected to Google's OAuth consent screen | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### "Already registered the google OAuth service" Error | ||
| This means Google OAuth is already configured. You can: | ||
| 1. Clear the MongoDB collection: `db.meteor_accounts_loginServiceConfiguration.remove({service: "google"})` | ||
| 2. Restart your Meteor app | ||
|
|
||
| ### "Service not configured" Error | ||
| This means the Google OAuth credentials are not properly set. Check: | ||
| 1. Environment variables are set correctly | ||
| 2. Google Cloud Console credentials are valid | ||
| 3. Redirect URIs match your app URL | ||
|
|
||
| ### "Invalid redirect_uri" Error | ||
| Make sure the redirect URI in Google Cloud Console exactly matches: | ||
| - Development: `http://localhost:3000/_oauth/google` | ||
| - Production: `https://yourdomain.com/_oauth/google` | ||
|
|
||
| ## Security Notes | ||
|
|
||
| - Never commit your `.env` file to version control | ||
| - Use different OAuth credentials for development and production | ||
| - Regularly rotate your client secrets | ||
| - Monitor OAuth usage in Google Cloud Console | ||
|
|
||
| ## Additional OAuth Providers | ||
|
|
||
| To add other OAuth providers (GitHub, Facebook, etc.), follow similar steps: | ||
|
|
||
| 1. Add the provider package: `meteor add accounts-github` | ||
| 2. Configure the service in `server/main.js` | ||
| 3. Add login buttons to your templates | ||
| 4. Handle the login events in your client code |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is slop. You don’t need this since it’s in the code or it should be generated from code. Note: more is not better. Elegance is simplicity.