Skip to main content

Get Current User

Returns the profile information for the currently authenticated user.

Authentication

access_token - JWT token in httpOnly cookie (automatically sent by browsers)

Response

integer
Internal user ID
integer
GitHub user ID
string
GitHub username (login)
string | null
User’s full name from GitHub profile
string | null
User’s email address from GitHub
string | null
URL to the user’s GitHub avatar image
string
ISO 8601 timestamp of when the user was created in the system

Error Responses

error
Not authenticated - The access_token cookie is missing
error
Invalid or expired token - The JWT token is invalid, malformed, or expired
error
User not found - The user ID from the token doesn’t exist in the database

User Model

The User model represents an authenticated user in the system.

Database Schema

integer
required
Primary key, auto-incremented
integer
required
Unique GitHub user ID, indexed for fast lookups
string
required
GitHub username (login)
string
required
Encrypted GitHub OAuth access token. Encrypted using Fernet (AES-128-CBC + HMAC-SHA256) derived from SECRET_KEY.
string | null
User’s email address from GitHub. May be null if email is private.
string | null
URL to the user’s GitHub avatar image
string | null
User’s full name from GitHub profile
datetime
Timestamp when the user was created (UTC, with timezone)
datetime
Timestamp when the user was last updated (UTC, with timezone)

Token Encryption

GitHub access tokens are encrypted at rest using symmetric encryption for security.

Implementation

Defined in app/auth/token_encryption.py:

Encryption Details

  • Algorithm: Fernet (AES-128-CBC + HMAC-SHA256)
  • Key Derivation: SHA-256 hash of SECRET_KEY, encoded as URL-safe base64
  • Security: Provides confidentiality and authenticity

Token Prefixes

The system recognizes these GitHub token prefixes for plaintext detection:
  • ghp_ - Personal access token
  • gho_ - OAuth access token
  • ghs_ - Server-to-server token
  • ghu_ - User access token
  • github_pat_ - Fine-grained personal access token

Migration Support

The decryption function gracefully handles legacy plaintext tokens. If a token cannot be decrypted but matches a GitHub token prefix, it’s returned as-is and a warning is logged. The token will be encrypted on the user’s next login.
If SECRET_KEY changes, all encrypted tokens become unreadable. Users must log out and sign in again to re-encrypt their tokens with the new key.