Overview
suSHi uses OAuth 2.0 for authentication with support for Google and GitHub providers. After successful authentication, a JWT token is issued and stored as an HTTP-only cookie.Get Authorization URL
GET /api/v1/auth/url
Retrieve the OAuth authorization URL for a specific provider.
Query Parameters
OAuth provider to use. Valid values:
google- Google OAuthgithub- GitHub OAuth
Response
Returns the authorization URL as plain text:Error Responses
OAuth Callback
GET /api/v1/auth/callback
Handles the OAuth callback from the provider. This endpoint is called automatically by the OAuth provider after user authorization.
Query Parameters
OAuth state parameter (automatically provided by OAuth provider)
Authorization code (automatically provided by OAuth provider)
Response
On success:- User is created in the database (if they don’t exist)
- JWT token is generated with 24-hour expiration
- Token is set as HTTP cookie with the following properties:
- Name:
jwt - HttpOnly:
false(⚠️ should betruein production for security) - SameSite:
Strict - Secure:
false(should betruein production with HTTPS) - Path:
/ - Expires: 24 hours from now
- Name:
- Redirects to
/dashboard.html(HTTP 303)
JWT Token Claims
The JWT token contains the following claims:User’s email address from OAuth provider
Issued at timestamp (Unix epoch)
Expiration timestamp (Unix epoch, 24 hours after issuance)
Error Responses
Logout
cURL
GET /api/v1/auth/logout
Invalidates the current JWT token by expiring the cookie.
Response
JWT Authentication for API Requests
All endpoints under/api/v1/* (except /api/v1/auth/*) require JWT authentication.
Implementation Details
- Algorithm: HS256 (HMAC-SHA256)
- Token Location: HTTP cookie named
jwt - Token Lifetime: 24 hours
- Middleware: Uses
jwtauthverifier and authenticator