Hanko Backend Integration Guide:About Hanko:Hanko is a modern open source authentication solution and the fastest way you integrate passkeys, 2FA, SSO, and more—with full control over your data. Move between self-hosted and Hanko Cloud anytime. No lock-in. Just Auth how it should be: secure, user friendly, and fully yours.What This Guide Covers: This guide demonstrates how to validate Hanko session tokens in your backend application. You’ll learn to implement session validation, create middleware for protecting endpoints, and authenticate requests using Hanko’s session management APIs.Key Technologies:
After successful authentication, Hanko generates a session token stored as a cookie. This guide shows how to validate these session tokens in your Go backend to authenticate API requests.
- Server-side programming language
- HTTP client libraries
- Middleware frameworks
- JSON handling
- Hanko session validation API
- Knowledge of your chosen backend language and framework
- Hanko Cloud account (sign up at cloud.hanko.io)
- Frontend application with Hanko authentication
- Set up Hanko API URL configuration from environment variables
- Implement session token validation using proper data structures
- Create reusable middleware or utilities for protecting API endpoints
- Handle session validation responses, errors, and edge cases
- Extract session tokens from HTTP cookies securely
- Build authentication utilities that integrate with your application architecture
- Implement comprehensive error handling and logging for production use
Get the Hanko API URL
Retrieve your project’s API URL from the Hanko Console. This URL is used to validate session tokens.If you are self-hosting Hanko, use your self-hosted instance URL instead.
Authentication flow
To authenticate requests in your Go backend:- Extract the session token from the HTTP cookie
- Validate the token using Hanko’s session validation API
- Allow or deny the request based on validation result