惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
GbyAI
GbyAI
L
LangChain Blog
B
Blog
博客园 - 三生石上(FineUI控件)
Martin Fowler
Martin Fowler
博客园 - 【当耐特】
Recent Announcements
Recent Announcements
P
Proofpoint News Feed
U
Unit 42
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿
小众软件
小众软件
I
InfoQ
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
C
Check Point Blog

Hacker News: Show HN

PurrrrrFocus: Pomodoro Timer App - App Store Workflow Engine — Multi-Step Orchestration for Bun RapidPhoto: Pro Photo Editor App - App Store GitHub - DheerG/swarms: Achieve extraordinary results with claude code across a variety of tasks SPICE simulation → oscilloscope → verification with Claude Code — Lucas Gerads Show HN: VCoding – A 5 MB native Windows IDE with no dynamic dependencies Show HN: LLMs don't hallucinate because they're bad at math, it's the format GitHub - Agent-FM/agentfm-core: AgentFM is a peer-to-peer network that turns everyday computers into a decentralized AI supercomputer. AgentFM lets you run massive AI workloads directly across a global mesh of idle CPUs and GPUs. Show HN: Tracking Top US Science Olympiad Alumni over Last 25 Years GitHub - Potarix/agent-hub: One place to talk to all your agents Show HN: Runtime security for AI agents(injection,tool abuse, data exfiltration) GitHub - dubeyKartikay/lazyspotify: Terminal Spotify client for macOS and Linux GitHub - the-banana-tool/king-louie: Easy to use GUI Personal AI Assistant. Win/Linux/Mac. Show HN I made my vacation rental bookable by AI agents–no Airbnb, 0% commission GitHub - basteez/jsf-autoreload: maven plugin to enable hot reload on jsf projects uvm32/hosts/host-gdbstub at main · ringtailsoftware/uvm32 GitHub - labsai/EDDI: Config-driven engine that turns JSON into production-grade AI agents. Multi-agent orchestration, 12+ LLM providers, MCP/A2A protocols, RAG, persistent memory, and enterprise compliance (EU AI Act, GDPR, HIPAA). Built on Quarkus. GitHub - glitchnsec/fortyone-oss: AI Executive Assistant Platform Quickstart | Alien GitHub - muxshed/shed: One stream in, or many. Every destination, simultaneously. No cloud middleman, no per-channel fees, no limits. GitHub - ocrbase-hq/ocrbase: 📄 PDF/IMG ->.MD/JSON Document OCR API for PaddleOCR and GLMOCR. Self-hostable. GitHub - impactjo/home-memory: MCP server that lets your AI assistant remember everything about your home. GitHub - Sets88/dbcls: DbCls is a powerful terminal database client that supports various databases GitHub - neptun2000/heor-agent-mcp GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh RollQuation: Math Puzzles - Apps on Google Play GitHub - dropbox/witchcraft Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis GitHub - opentalon/opentalon: OpenTalon is an open-source platform built from the ground up in Go as a robust alternative to OpenClaw LinkedIn™ 职位抓取工具 - Chrome 应用商店
Introducing Limen: composable authentication for Go | Limen
brianiyoha · 2026-04-25 · via Hacker News: Show HN

Limen is out today: a modern, composable authentication library for Go.

If you've ever built auth in Go, you know the drill. You pull in bcrypt, glue it to database/sql, reach for golang-jwt or roll your own sessions, wire up golang.org/x/oauth2, add a CSRF package, remember to set SameSite, forget to rotate something, and six files later you have a fragile thing you don't want to touch. Meanwhile the JavaScript ecosystem has better-auth: one import, composable plugins, sensible defaults.

Limen brings that developer experience to Go, while staying idiomatic: small interfaces, explicit configuration, no magic, no framework lock-in.

Limen is a plugin-first authentication library. The core ships with the things every auth system needs: session management, cookie handling, schema, hooks, rate limiting, and security primitives. Every authentication method lives in its own importable Go module.

You compose exactly the auth stack your application needs:

  • Credential/password: plugins/credential-password
  • OAuth 2.0: a generic provider plus ready-made plugins for Google, GitHub, Apple, Microsoft, Discord, Facebook, LinkedIn, Spotify, Twitch, and X
  • Two-factor authentication: plugins/two-factor (TOTP, backup codes)
  • Database adapters: adapters/gorm or adapters/sql

Design goals

  • Framework-agnostic. Limen exposes an http.Handler. It drops into net/http, Gin, Echo, Chi, Fiber, or anywhere an http.Handler fits.
  • Bring your own database. PostgreSQL, MySQL, SQLite, SQL Server, via database/sql or GORM. Add your own adapter for anything else.
  • Type-safe configuration. Plugins are configured with functional options, not string maps. You get autocomplete, and the compiler catches typos.
  • Secure defaults. HttpOnly + Secure cookies, SameSite=Lax, CSRF protections, password hashing with sane cost factors, session rotation on privilege changes.
  • Extensible. First-class hooks, a clean Plugin interface, and a schema system that lets you add custom user fields without forking.

Let's build a real auth layer from scratch: sign up, sign in, protected route, OAuth, and 2FA. You'll need Go 1.25+ and a Postgres database.

1. Install

go get github.com/thecodearcher/limen
go get github.com/thecodearcher/limen/adapters/sql
go get github.com/thecodearcher/limen/plugins/credential-password

2. Wire up the core

Create main.go:

package main

import (
	"database/sql"
	"log"
	"net/http"
	"os"

	_ "github.com/lib/pq"

	"github.com/thecodearcher/limen"
	sqladapter "github.com/thecodearcher/limen/adapters/sql"
	credentialpassword "github.com/thecodearcher/limen/plugins/credential-password"
)

func main() {
	db, err := sql.Open("postgres", os.Getenv("DATABASE_URL"))
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	auth, err := limen.New(&limen.Config{
		BaseURL:  "http://localhost:8080",
		Database: sqladapter.NewPostgreSQL(db),
		Secret:   []byte(os.Getenv("LIMEN_SECRET")), // 32 bytes
		Plugins: []limen.Plugin{
			credentialpassword.New(),
		},
	})
	if err != nil {
		log.Fatal(err)
	}

	mux := http.NewServeMux()
	mux.Handle("/api/auth/", auth.Handler())

	log.Println("listening on :8080")
	log.Fatal(http.ListenAndServe(":8080", mux))
}

That's a full auth server. auth.Handler() mounts everything the enabled plugins expose under /api/auth/. No manual route wiring.

Generate the schema migrations with the limen CLI, apply them to your database, set LIMEN_SECRET to a 32-byte value (openssl rand -hex 16 will do), and you're up.

3. Sign up and sign in

credential-password contributes two endpoints:

POST /api/auth/signup/credential
Content-Type: application/json

{ "email": "[email protected]", "password": "correct-horse-battery" }
POST /api/auth/signin/credential
Content-Type: application/json

{ "credential": "[email protected]", "password": "correct-horse-battery" }

On success, Limen creates a session and sets a signed, HttpOnly cookie.

4. Protect a route

The same auth value you passed plugins into is how you read the session back out:

mux.HandleFunc("GET /api/me", func(w http.ResponseWriter, r *http.Request) {
	session, err := auth.GetSession(r)
	if err != nil || session == nil {
		http.Error(w, "Unauthorized", http.StatusUnauthorized)
		return
	}
	// session.User and session.Session are fully typed
	json.NewEncoder(w).Encode(session.User)
})

Use it in middleware, in a handler, in a Gin context. Limen doesn't care; it only needs the *http.Request.

5. Add Google OAuth

Two go gets and a line of config:

go get github.com/thecodearcher/limen/plugins/oauth
go get github.com/thecodearcher/limen/plugins/oauth-google
import (
	"github.com/thecodearcher/limen/plugins/oauth"
	oauthgoogle "github.com/thecodearcher/limen/plugins/oauth-google"
)

auth, _ := limen.New(&limen.Config{
	// ... BaseURL, Database, Secret ...
	Plugins: []limen.Plugin{
		credentialpassword.New(),
		oauth.New(oauth.WithProviders(
			oauthgoogle.New(),
		)),
	},
})

Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET in your environment and you're done. If you'd rather pass them explicitly, oauthgoogle.WithClientID(...) and WithClientSecret(...) are there.

Limen now exposes:

GET  /api/auth/oauth/google/authorize?callback_url=https://yourapp.com/callback
GET  /api/auth/oauth/google/callback

It handles the PKCE flow, state verification, token exchange, profile fetch, and links or creates the user, then drops them into the same session system the email/password flow uses. auth.GetSession(r) works exactly the same way, regardless of how the user signed in.

Want GitHub too? Add oauthgithub.New(...) to WithProviders. That's the whole change.

6. Turn on 2FA

go get github.com/thecodearcher/limen/plugins/two-factor
import twofactor "github.com/thecodearcher/limen/plugins/two-factor"

Plugins: []limen.Plugin{
	credentialpassword.New(),
	oauth.New( /* ... */ ),
	twofactor.New(),
},

Your users can now enroll a TOTP authenticator and download backup codes. On the next sign-in, they get a 2FA challenge instead of an immediate session. Limen handles the challenge state, step-up flow, and recovery codes.

7. Add a custom field without forking

Need a display_name on every user? Use the schema system:

limen.WithSchemaUser(
	limen.WithUserAdditionalFields(func(ctx *limen.AdditionalFieldsContext) (map[string]any, error) {
		if ctx.IsEmpty("display_name") {
			return nil, limen.NewLimenError("display_name is required", http.StatusBadRequest, nil)
		}
		return map[string]any{
			"display_name": ctx.GetBodyValue("display_name"),
		}, nil
	}),
)

Extra fields on the sign-up body land directly in your user row. No migration dance, no plugin rewrite.

Out of the box, Limen gives you:

  • A core with sessions (DB- or cache-backed), cookies, CSRF, rate limiting, email verification, hooks, schema, and typed errors
  • Auth method plugins: credential/password, two-factor, and OAuth with 10+ ready-made social providers
  • SQL and GORM database adapters, covering Postgres, MySQL, and SQLite
  • A limen CLI for scaffolding and migrations
  • Runnable examples covering the common setups: net/http, Gin, GORM, OAuth, and two-factor
  • @limen/client: a typed TypeScript client with full API surface coverage
  • @limen/react: React hooks (useSession, useLimen) built on top of the client
  • More plugins: magic links, passkeys (WebAuthn), SSO/SAML, organizations & teams
  • More database adapters

Open an issue if you hit something. Open a PR if you want a plugin that doesn't exist yet. Limen is designed to be extended. That's the whole point.

Go deserves better auth. Let's build it ❤️