Quickstart: add sign-in to a web app with a backend
This guide shows how to add Leantel Auth to a web app with a backend.
leantel.dev/auth.md and it can complete these steps for you.1. Set up Auth
In the console home, choose Set up Auth on the Auth card. Name your app, pick Web app with a backend, add your redirect URL and choose Create app. On the Connect step, copy the client ID and secret into LEANTEL_CLIENT_ID and LEANTEL_CLIENT_SECRET. The secret is shown only once.
2. Add an OpenID Connect client
You can use any certified OpenID Connect library. Configure it with the Leantel issuer URL, and the library discovers the remaining endpoints automatically.
provider, err := oidc.NewProvider(ctx, "https://auth.leantel.dev")
if err != nil {
return err
}
config := oauth2.Config{
ClientID: os.Getenv("LEANTEL_CLIENT_ID"),
ClientSecret: os.Getenv("LEANTEL_CLIENT_SECRET"),
RedirectURL: "https://app.example.com/auth/callback",
Endpoint: provider.Endpoint(),
Scopes: []string{oidc.ScopeOpenID, "email"},
}const config = await oidc.discovery(
new URL("https://auth.leantel.dev"),
process.env.LEANTEL_CLIENT_ID!,
process.env.LEANTEL_CLIENT_SECRET!,
);3. Protect your API
Verify the access token on every request to your API. Verification runs locally and doesn't call Leantel.
protect := authverify.Middleware(issuer, "api_example")
http.Handle("/orders", protect(orders))4. Try it
Start your app and choose Sign in. You're redirected to your branded sign-in page and, after signing in, returned to your app.
Complete guides by stack
Each guide is a complete, tested app that signs people in and out, protects an API route and receives webhooks.