Skip to main content

LINEAR-123: Complete Ticket Lifecycle Example

This example demonstrates a complete ticket lifecycle from start to finish, showing all Linear MCP interactions, progress updates, and status transitions.

Ticket Details

ID: LINEAR-123 Title: Add user authentication with OAuth2 Type: Feature Priority: High Status: Done Assignee: Backend Developer Agent Created: 2025-01-08 Completed: 2025-01-10

Phase 1: Ticket Start (Day 1 - Morning)

1. Fetch Ticket Details

mcp__linear__get_issue
  issue_id: "LINEAR-123"
Response:
{
  "id": "LINEAR-123",
  "title": "Add user authentication with OAuth2",
  "description": "Implement OAuth2 authentication flow supporting Google, GitHub, and Microsoft providers...",
  "status": "Todo",
  "priority": "High",
  "assignee": "backend-developer",
  "labels": ["auth", "security", "backend"],
  "acceptance_criteria": [
    "Users can sign in with Google OAuth2",
    "Users can sign in with GitHub OAuth2",
    "Users can sign in with Microsoft OAuth2",
    "JWT tokens generated with 24-hour expiry",
    "Refresh token mechanism implemented",
    "User profile data synced from OAuth provider"
  ]
}

2. Update Status to “In Progress”

mcp__linear__update_issue
  issue_id: "LINEAR-123"
  status: "In Progress"

3. Add Initial Comment with Implementation Plan

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "Starting work on LINEAR-123

## Implementation Plan

### Phase 1: OAuth Provider Setup
- Configure OAuth apps for Google, GitHub, Microsoft
- Set up environment variables for client IDs/secrets
- Create provider configuration module

### Phase 2: Backend API
- Create /auth/oauth/:provider endpoint
- Implement OAuth callback handling
- JWT token generation service
- Refresh token mechanism

### Phase 3: Database Schema
- Create users table with OAuth fields
- Create oauth_providers table
- Set up RLS policies

### Phase 4: Testing & Documentation
- Unit tests for auth service
- Integration tests for OAuth flows
- API documentation update

**Branch**: feature/LINEAR-123-oauth2-authentication
**Estimated Time**: 2-3 days

Will provide progress updates as I complete each phase."

Phase 1 Complete (Day 1 - Afternoon)

4. Progress Update After Phase 1

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "**Phase 1 Complete** ✅

Completed tasks:
- ✅ Configured OAuth apps for all 3 providers
- ✅ Added environment variables to .env.example
- ✅ Created src/config/oauth-providers.ts with provider configs
- ✅ Set up OAuth redirect URLs

**Commits**:
- a1b2c3d feat(auth): add OAuth provider configurations
- e4f5g6h chore(config): add OAuth environment variables

**Progress**: 25% complete
**Files Changed**:
- src/config/oauth-providers.ts (new)
- .env.example (updated)
- README.md (updated with OAuth setup instructions)

**Next**: Starting Phase 2 - Backend API implementation

**Notes**: All OAuth apps approved and ready for testing in development environment."

Phase 2 Complete (Day 1 - Evening)

5. Technical Decision Documented

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "**Technical Decision Made**

**Decision**: Use Passport.js library for OAuth implementation instead of custom implementation.

**Rationale**:
- Well-tested, maintained library (45k stars)
- Supports all our target providers out-of-box
- Reduces custom code by ~300 lines
- Better security (battle-tested)
- Easier to add new providers later

**Trade-offs**:
- Adds dependency (~200KB)
- Learning curve for team (mitigated by good docs)

**Implementation**: Installing passport, passport-google-oauth20, passport-github2, passport-microsoft"

6. Phase 2 Progress Update

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "**Phase 2 Complete** ✅

Completed tasks:
- ✅ Installed Passport.js and provider strategies
- ✅ Created /auth/oauth/:provider endpoint
- ✅ Implemented OAuth callback handling
- ✅ Built JWT token generation service
- ✅ Added refresh token mechanism with 7-day expiry

**Commits**:
- h7i8j9k feat(auth): add OAuth endpoints with Passport.js
- l0m1n2o feat(auth): implement JWT token service
- p3q4r5s feat(auth): add refresh token mechanism

**Progress**: 50% complete
**Files Changed**:
- src/routes/auth.ts (new)
- src/services/AuthService.ts (new)
- src/services/TokenService.ts (new)
- src/middleware/passport.ts (new)

**API Endpoints Created**:
- POST /api/auth/oauth/google
- POST /api/auth/oauth/github
- POST /api/auth/oauth/microsoft
- GET /api/auth/callback/:provider
- POST /api/auth/refresh

**Next**: Starting Phase 3 - Database schema implementation"

Blocker Encountered (Day 2 - Morning)

7. Blocker Reported

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "⚠️ **Blocker Encountered**

**Issue**: DBA agent needs to create database schema before I can proceed with data persistence.

**Impact**: Blocks Phase 3 implementation

**Estimated Delay**: 2-4 hours (waiting on DBA agent)

**Attempted Solutions**:
- Checked if existing schema could be extended (not compatible)
- Considered temporary in-memory storage (not suitable for OAuth data)

**Need**: DBA agent to create:
- users table with OAuth fields (provider, provider_id, email, profile_data)
- oauth_tokens table (access_token, refresh_token, expires_at)
- Proper indexes and RLS policies

**Next Steps**:
- Will document schema requirements for DBA
- Meanwhile, will work on Phase 4 unit tests (can be done in parallel)
- Will mock database calls in tests"

8. Update Status to Blocked

mcp__linear__update_issue
  issue_id: "LINEAR-123"
  status: "Blocked"

Blocker Resolved (Day 2 - Afternoon)

9. Blocker Resolution Update

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "✅ **Blocker Resolved**

DBA agent has created the database schema:
- users table created with OAuth fields
- oauth_tokens table created
- Indexes added for email and provider_id
- RLS policies configured

**Commits from DBA**:
- t6u7v8w feat(db): add users table for OAuth authentication
- x9y0z1a feat(db): add oauth_tokens table

**Action**: Resuming Phase 3 implementation now."

10. Update Status Back to In Progress

mcp__linear__update_issue
  issue_id: "LINEAR-123"
  status: "In Progress"

Phase 3 Complete (Day 2 - Late Afternoon)

11. Phase 3 Progress Update

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "**Phase 3 Complete** ✅

Completed tasks:
- ✅ Integrated AuthService with database
- ✅ Implemented user creation/update on OAuth login
- ✅ Added token persistence to oauth_tokens table
- ✅ Implemented token cleanup for expired tokens
- ✅ Added user profile sync from OAuth providers

**Commits**:
- b2c3d4e feat(auth): integrate OAuth with database
- f5g6h7i feat(auth): add user profile sync
- j8k9l0m refactor(auth): extract database operations to repository

**Progress**: 75% complete
**Files Changed**:
- src/services/AuthService.ts (updated)
- src/repositories/UserRepository.ts (new)
- src/repositories/OAuthTokenRepository.ts (new)

**Database Operations**:
- User CRUD operations working
- Token storage and retrieval working
- Automatic cleanup of expired tokens (cron job)

**Next**: Starting Phase 4 - Testing & Documentation"

Phase 4 Complete (Day 2 - Evening)

12. Phase 4 Progress Update

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "**Phase 4 Complete** ✅

Completed tasks:
- ✅ Unit tests for AuthService (100% coverage)
- ✅ Unit tests for TokenService (100% coverage)
- ✅ Integration tests for OAuth flows (all 3 providers)
- ✅ API documentation updated in OpenAPI spec
- ✅ README updated with OAuth setup instructions
- ✅ Environment variables documented

**Commits**:
- n1o2p3q test(auth): add comprehensive AuthService tests
- r4s5t6u test(auth): add OAuth flow integration tests
- v7w8x9y docs(api): update OpenAPI spec with OAuth endpoints

**Progress**: 100% complete
**Test Results**:
- Unit tests: 48/48 passing
- Integration tests: 12/12 passing
- Coverage: 98.7%

**Documentation**:
- API endpoints documented in Swagger
- Setup guide in README
- Environment variables in .env.example

**Status**: Ready for review and testing"

Ready for Review (Day 2 - Evening)

13. Mark Ready for Review

mcp__linear__update_issue
  issue_id: "LINEAR-123"
  status: "In Review"

14. Add Final Implementation Comment

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "**Implementation Complete** ✅

## Summary

Successfully implemented OAuth2 authentication for Google, GitHub, and Microsoft providers.

**Features Implemented**:
- ✅ OAuth2 authentication flow for 3 providers
- ✅ JWT token generation with 24-hour expiry
- ✅ Refresh token mechanism with 7-day expiry
- ✅ User profile sync from OAuth providers
- ✅ Automatic token cleanup
- ✅ Comprehensive test coverage (98.7%)

**Acceptance Criteria Status**:
- ✅ Users can sign in with Google OAuth2
- ✅ Users can sign in with GitHub OAuth2
- ✅ Users can sign in with Microsoft OAuth2
- ✅ JWT tokens generated with 24-hour expiry
- ✅ Refresh token mechanism implemented
- ✅ User profile data synced from OAuth provider

**Technical Details**:
- **Library**: Passport.js for OAuth implementation
- **Security**: Tokens stored with bcrypt hashing
- **Database**: users and oauth_tokens tables
- **API**: 5 new endpoints created
- **Tests**: 60 tests, 98.7% coverage

**Branch**: feature/LINEAR-123-oauth2-authentication
**Commits**: 15 commits (will be squashed to 3)
**Lines Changed**: +1,247 -32

**Pull Request**: #45
**Ready for**: Security scan → QA testing → Deployment

**Notes**:
- All environment variables documented in .env.example
- OAuth apps configured in Google, GitHub, Microsoft consoles
- Tested with real OAuth flows in development environment"

Code Review Feedback (Day 3 - Morning)

15. Code Review Feedback Addressed

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "**PR Review Feedback Addressed**

**Feedback from @reviewer**:
1. Add rate limiting to OAuth endpoints
2. Implement CSRF protection for OAuth callbacks
3. Add logging for failed OAuth attempts
4. Update token expiry to 1 hour (not 24 hours)

**Changes Made**:
- ✅ Added express-rate-limit middleware (5 req/min per IP)
- ✅ Implemented CSRF token validation using csurf
- ✅ Added Winston logging for all auth events
- ✅ Updated JWT expiry to 1 hour as requested

**Commits**:
- z0a1b2c feat(auth): add rate limiting to OAuth endpoints
- d3e4f5g feat(auth): implement CSRF protection
- h6i7j8k feat(auth): add comprehensive auth logging
- l9m0n1o fix(auth): reduce JWT expiry to 1 hour

**Files Changed**:
- src/middleware/rateLimiter.ts (new)
- src/middleware/csrf.ts (new)
- src/config/logger.ts (updated)
- src/services/TokenService.ts (updated)

**Re-tested**: All tests still passing with new changes.
**Security**: Rate limiting and CSRF protection verified.

**Status**: Ready for re-review"

QA Testing Complete (Day 3 - Afternoon)

16. QA Approval

mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "**QA Testing Complete** ✅

**Tested by**: senior-qa-engineer agent

**Test Results**:
- ✅ Functional testing: 18/18 passed
- ✅ Integration testing: 12/12 passed
- ✅ Security testing: 8/8 passed
- ✅ Performance testing: Passed (avg 120ms response time)
- ✅ Accessibility testing: N/A (backend only)

**Test Scenarios Covered**:
1. Google OAuth login flow - PASS
2. GitHub OAuth login flow - PASS
3. Microsoft OAuth login flow - PASS
4. JWT token generation - PASS
5. Refresh token flow - PASS
6. Token expiry handling - PASS
7. Invalid provider handling - PASS
8. Rate limiting enforcement - PASS
9. CSRF protection - PASS
10. Concurrent login attempts - PASS

**Performance**:
- OAuth flow completion: 1.2s avg
- Token refresh: 85ms avg
- Database queries: <50ms avg

**Issues Found**: None

**Status**: ✅ APPROVED FOR DEPLOYMENT"

Deployment (Day 3 - Evening)

17. Deployment Complete

mcp__linear__update_issue
  issue_id: "LINEAR-123"
  status: "Done"
mcp__linear__add_comment
  issue_id: "LINEAR-123"
  comment: "**Completed and Deployed** 🚀

## Deployment Summary

- **Environment**: Production
- **Deployed**: 2025-01-10 18:30 UTC
- **Deploy Method**: Blue-green deployment
- **Downtime**: 0 seconds
- **Rollback Plan**: Available if needed

## What Was Deployed

- OAuth2 authentication for Google, GitHub, Microsoft
- JWT token service with 1-hour expiry
- Refresh token mechanism
- Rate limiting and CSRF protection
- Comprehensive logging

## Post-Deployment Verification

✅ All health checks passing
✅ OAuth endpoints responding (avg 110ms)
✅ Database connections stable
✅ No errors in logs
✅ Monitoring dashboards green

## Metrics

- **Deployment time**: 3 minutes
- **Tests run**: 60 tests, 100% passing
- **Database migrations**: 2 migrations applied successfully
- **Rollback tested**: Yes, working

## Final Stats

- **Branch**: feature/LINEAR-123-oauth2-authentication
- **Commits**: 19 commits (squashed to 3 for main branch)
- **PR**: #45 (merged)
- **Files changed**: 28 files
- **Lines added**: 1,389
- **Lines removed**: 47
- **Test coverage**: 98.7%

## Documentation

- API docs updated: https://api.example.com/docs
- Setup guide: README.md
- Environment variables: .env.example

## Follow-up Items

Created LINEAR-456 for OAuth provider expansion (Apple, Twitter)

---

**Work complete!** Ticket closing automatically."

Summary

This ticket demonstrates a complete lifecycle including:
  1. Initial setup - Fetched ticket, updated status, created plan
  2. Progress tracking - Regular updates after each phase
  3. Technical decisions - Documented choice of Passport.js
  4. Blocker handling - Reported blocker, resolved, resumed work
  5. Code review - Addressed feedback, re-tested
  6. QA testing - Comprehensive testing by QA agent
  7. Deployment - Successful production deployment
  8. Completion - Final stats and metrics documented
Total Duration: 3 days Total Comments: 17 updates Status Transitions: Todo → In Progress → Blocked → In Progress → In Review → Done This example follows all best practices from the Linear Integration skill.