kayan

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: Apache-2.0

README

Kayan

Go Reference Go Version Build Status Test Status Coverage Go Report Card License Release

Kayan is a headless, non-generic, extensible Identity & Access Management (IAM) library for Go.


Why Kayan?

Challenge Kayan's Solution
IAM solutions force their schema BYOS - Bring Your Own Schema
Go generics are complex Non-generic design with interfaces
Need UI flexibility Headless - no opinions on frontend
Single auth method lock-in Strategy pattern - mix methods
Scaling concerns Stateless sessions, pluggable storage

Quick Start

import (
    "github.com/getkayan/kayan/core/flow"
    "github.com/getkayan/kayan/core/session"
    "github.com/getkayan/kayan/kgorm"
)

// 1. Your model
type User struct {
    ID           string `gorm:"primaryKey"`
    Email        string `gorm:"uniqueIndex"`
    PasswordHash string
}
func (u *User) GetID() any   { return u.ID }
func (u *User) SetID(id any) { u.ID = id.(string) }

// 2. Setup
db, _ := gorm.Open(sqlite.Open("app.db"), &gorm.Config{})
repo := kgorm.NewRepository(db)
factory := func() any { return &User{} }

// 3. Registration
regManager := flow.NewRegistrationManager(repo, factory)
hasher := flow.NewBcryptHasher(10)
pwStrategy := flow.NewPasswordStrategy(repo, hasher, "", factory)
pwStrategy.MapFields([]string{"Email"}, "PasswordHash")
regManager.RegisterStrategy(pwStrategy)

// 4. Login
loginManager := flow.NewLoginManager(repo)
loginManager.RegisterStrategy(pwStrategy)

// 5. Sessions
sessManager := session.NewManager(session.NewHS256Strategy(secret, 24*time.Hour))

Key Features

Authentication Strategies
  • Password - Bcrypt, argon2
  • OIDC - Google, GitHub, Microsoft
  • WebAuthn - Passkeys, FIDO2
  • SAML 2.0 - Enterprise SSO
  • Magic Link - Passwordless email
  • TOTP - Two-factor authentication
Session Management
  • JWT - Stateless tokens
  • Database - Revocable sessions
  • Rotation - Access/refresh patterns
Authorization
  • RBAC - Role-based access
  • ABAC - Attribute-based policies
  • Hybrid - Combined RBAC+ABAC
Enterprise
  • Multi-tenancy - Tenant isolation
  • Audit logging - Compliance ready
  • Rate limiting - Brute-force protection

Documentation

Getting Started
Concepts
Architecture
Reference
SDKs
Examples

Ecosystem

Package Description
kayan Core library
kayan-echo Echo framework integration
kayan-js TypeScript SDK
kayan-console Admin UI (Next.js)
kayan-examples Working examples

License

Apache 2.0

Directories

Path Synopsis
cmd
kayan-cli command
core module
kgorm module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL