devstygian / devstygian/Resto-POS

feat(auth): implement Google OAuth 2.0 authentication

Open
#88 0 comments 0 reactions 1 assignee Claimed by @devstygian View on GitHub
authentication backend documentation frontend help wanted Important Top Priority
Dominant language
PHP
Stars
4
Forks
5
PR merge metrics
No merged PRs in 30d

Description

## Summary

Implement Google OAuth 2.0 authentication to provide a secure and convenient login method for administrators and staff members.

The existing email and password authentication should remain available as an alternative login option.

---

## Objectives

- Integrate Google Sign-In.
- Authenticate users using Google OAuth 2.0.
- Automatically create user accounts during first-time login.
- Link existing accounts based on email address.
- Maintain secure user sessions.

---

## Functional Requirements

- [ ] Add a "Continue with Google" button to the login page.
- [ ] Authenticate users through Google OAuth.
- [ ] Retrieve user profile information.
- [ ] Automatically create accounts for new users.
- [ ] Link existing accounts using email matching.
- [ ] Store authentication provider information.
- [ ] Maintain user sessions after authentication.
- [ ] Support secure logout.

---

## User Information

Store the following information:

- Google ID
- Full Name
- Email Address
- Profile Picture (optional)
- Authentication Provider
- Last Login Timestamp

---

## Database Changes

### users

Add the following fields:

- google_id
- avatar
- auth_provider
- last_login

Example values for `auth_provider`:

- local
- google

---

## Security Requirements

- Validate Google ID Tokens.
- Prevent duplicate user accounts.
- Use secure session management.
- Restrict authentication to verified Google accounts.
- Protect OAuth credentials using environment variables.

---

## Acceptance Criteria

- Users can authenticate using Google Sign-In.
- Existing email/password authentication remains functional.
- Duplicate accounts are prevented.
- User information is stored correctly.
- Sessions remain active after successful authentication.
- Logout terminates the authenticated session securely.

---

## References

Google Identity Services

https://developers.google.com/identity

Google API Client for PHP

https://github.com/googleapis/google-api-php-client

---

## Priority

Medium

## Labels

enhancement
authentication
oauth
security
google
backend

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.