mirror of
https://github.com/hanzoai/iam.git
synced 2026-11-19 18:37:16 +00:00
- httpx.Caller reads the caller from facts the caller cannot write: the host's stamped X-Client-Ip over its socket, or the nearest proxy's appended hop behind it. CF-Connecting-IP is no longer read, since api.hanzo.ai is not behind a proxy that rewrites it, so a limit keyed on it was a limit the caller set. IPv6 is bucketed by /48 (a site's allocation), not /64, so a caller cannot rotate addresses inside one allocation. - The open-request budgets (number, day, ceiling) are charged only by open requests: a second factor is admitted against its own reserved budget, so a stranger filling the open budgets cannot lock a holder out of their own code. Budgets are scoped by tenant where they are money (day), and counted by counter rows instead of COUNT scans, so a refusal costs O(1) however many rows the ledger holds. - Signup refuses a phone number already registered in the org, closing the squatting that needed no proof to take one.
69 lines
2.7 KiB
Go
69 lines
2.7 KiB
Go
// Copyright 2026 Hanzo AI, Inc.
|
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
|
|
// Package schema declares the fifteen IAM v2 identity entities on
|
|
// hanzoai/orm.
|
|
//
|
|
// Each entity embeds orm.Model[T]; every kind is registered exactly once in
|
|
// this file's init(). orm stores every entity as one row in a single
|
|
// _entities table keyed by kind — there is no per-entity DDL, so "schema"
|
|
// here is the domain model, not a migration. Phase 1 carries the full field
|
|
// set per entity, each in its own file beside the handlers that own it
|
|
// (MIGRATION.md §4); the (owner, name) pair is the natural key across the
|
|
// whole model.
|
|
//
|
|
// Registration is centralized here — one place, one way. The per-entity
|
|
// files declare only the struct (and its nested value types); they add no
|
|
// second orm.Register call, which would panic on a duplicate kind.
|
|
//
|
|
// Scope is deliberate: the v1 the legacy surface object package has ~32 tables, but the
|
|
// Casbin artifacts (adapter, enforcer, model) are replaced by hanzoai/authz
|
|
// and the commerce tables (payment, plan, product, subscription) belong to
|
|
// other services. Only identity entities live here.
|
|
package schema
|
|
|
|
import "github.com/hanzoai/orm"
|
|
|
|
// Kinds lists the registered v2 entity kinds in canonical (MIGRATION.md §4)
|
|
// order. The drift-compare tool and diagnostics iterate this.
|
|
func Kinds() []string {
|
|
return []string{
|
|
"users", "organizations", "applications", "providers",
|
|
"roles", "permissions", "certs", "keys",
|
|
"webauthn_credentials", "sessions", "tokens", "audit_logs",
|
|
"invitations", "verifications", "projects", "workspaces",
|
|
"federation_states", "challenges", "wallets", "login_challenges",
|
|
"memberships", "teams", "tombstones", "sightings",
|
|
"texts", "text_tallies",
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
orm.Register[User]("users")
|
|
orm.Register[Organization]("organizations")
|
|
orm.Register[Application]("applications")
|
|
orm.Register[Provider]("providers")
|
|
orm.Register[Role]("roles")
|
|
orm.Register[Permission]("permissions")
|
|
orm.Register[Cert]("certs")
|
|
orm.Register[Key]("keys")
|
|
orm.Register[WebauthnCredential]("webauthn_credentials")
|
|
orm.Register[Session]("sessions")
|
|
orm.Register[Token]("tokens")
|
|
orm.Register[AuditLog]("audit_logs")
|
|
orm.Register[Invitation]("invitations")
|
|
orm.Register[VerificationRecord]("verifications")
|
|
orm.Register[Project]("projects")
|
|
orm.Register[Workspace]("workspaces")
|
|
orm.Register[FederationState]("federation_states")
|
|
orm.Register[Challenge]("challenges")
|
|
orm.Register[Wallet]("wallets")
|
|
orm.Register[Tombstone]("tombstones")
|
|
orm.Register[LoginChallenge]("login_challenges")
|
|
orm.Register[Membership]("memberships")
|
|
orm.Register[Team]("teams")
|
|
orm.Register[Sighting]("sightings")
|
|
orm.Register[Text]("texts")
|
|
orm.Register[TextTally]("text_tallies")
|
|
}
|