Cloudrive

Authentication

Authula serves every auth endpoint under /v1/auth and issues the JWT pairs the rest of the API accepts.

Authentication is handled by Authula, wired in cmd/api/authula.go and mounted with the Fiber adapter at /v1/auth.

Plugins

PluginConfiguration
jwtAccess tokens 15 minutes, refresh tokens 7 days.
bearerValidates Authorization: Bearer <jwt> on API routes.
sessionHttpOnly session cookie (__Host-authula.session_token outside dev) used to exchange OAuth2/OIDC redirects for JWTs at POST /v1/auth/token.
emailResend, from RESEND_FROM_EMAIL.
email-passwordPasswords 8–128 chars, email verification required, auto sign-in, verification and reset emails from templates/emails.
magic-linkLinks valid 15 minutes.
oauth2Google (GOOGLE_CLIENT_ID/SECRET) and generic OIDC (OIDC_ISSUER/CLIENT_ID/CLIENT_SECRET via discovery); scopes openid email profile.

A response hook adds expires_in / expires_at to every token-issuing response so clients can refresh proactively.

Endpoints

EndpointAuthReturns
POST /v1/auth/email-password/sign-upoptionalToken pair
POST /v1/auth/email-password/sign-inoptionalToken pair
GET /v1/auth/email-password/verify-emailoptional
POST /v1/auth/email-password/send-email-verificationbearer
POST /v1/auth/email-password/request-password-resetbearer
POST /v1/auth/email-password/change-passwordbearer
POST /v1/auth/email-password/request-email-changebearer
POST /v1/auth/magic-link/sign-inoptionalSends the email
GET /v1/auth/magic-link/verifyoptionalRedirects to callback_url?token=…
POST /v1/auth/magic-link/exchangeoptionalToken pair
GET /v1/auth/providerspublicEnabled sign-in methods & Turnstile
POST /v1/auth/tokensessionToken pair (from OAuth2/OIDC cookie)
GET /v1/auth/oauth2/authorize/googleoptionalRedirect to Google
GET /v1/auth/oauth2/callback/googleoptionalRedirect to redirect_to
GET /v1/auth/oauth2/authorize/oidcoptionalRedirect to OIDC provider
GET /v1/auth/oauth2/callback/oidcoptionalRedirect to redirect_to
POST /v1/auth/token/refresh—Rotated token pair
GET /v1/auth/mebearerAuthula user
POST /v1/auth/sign-outbearer

"Token pair" is { access_token, refresh_token, token_type, expires_in, expires_at } (the sign-in routes run jwt.respond_json). redirect_to and callback_url are checked against the trusted origins (CORS_ALLOWED_ORIGINS).

Users in two schemas

Authula owns its tables in the authula schema. A service hook (syncUserToApp) upserts every created or updated Authula user into public.users, splitting the display name into first and last name and reading the global role from user metadata (default user). Application handlers only read public.users.

GET /v1/me (an application route, not Authula's) returns that application user; the frontend uses it as its session probe.

The super user

With SUPER_USER=email:password, every boot makes sure that account exists, is verified, carries role=super_user, and has a password credential. The password is set only on creation, so changing it later survives restarts.

Protecting application routes

middlewares.Authorization() (in internal/middlewares/authorization.go) reads the bearer token, validates it through Authula's JWT service, and stores the user id in the request context; handlers read it with currentUser(c). A missing or invalid token answers:

{ "message": "Unauthorized, invalid bearer token" }

On this page