mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-15 12:58:33 +00:00
o11y carried a second identity system: email/password sign-in, Google,
OIDC and SAML callbacks, self-registration, invites, reset-password
tokens, roles-on-users, SSO auth domains, and a pair of tokenizers that
minted and stored its own sessions. Hanzo IAM answers all of it, once,
at the edge. Two credential stores is one too many, and the one nobody
signs into is the one that rots.
What is left is Identity: WHO a request is, resolved from what the edge
asserted or from a service-account key, never issued here. The routes are
not merely unrouted — the handlers, stores, tables and templates behind
them are gone, and anonymous_test.go names each dead address so that
re-exempting one fails even though no route can come back.
The census moves with it: 366 addresses to 329, 353 typed ops to 319, ten
escape hatches to seven. zipdoc_gen.go loses the 34 descriptions whose
addresses left, because zip keys its doc registry by method and path, so
a description outliving its declaration attaches this module's prose to
whatever a host serves at that address. zipdoc_test.go pins that.
Cherry-picked from delete/o11y-identity 89854a68ae.
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package user
|
|
|
|
import (
|
|
"github.com/hanzoai/o11y/pkg/errors"
|
|
"github.com/hanzoai/o11y/pkg/factory"
|
|
"github.com/hanzoai/o11y/pkg/valuer"
|
|
)
|
|
|
|
// Config is what remains once o11y stopped holding credentials: WHICH row the
|
|
// local single-user mode stands in for, and nothing about how anyone proves who
|
|
// they are. The password reset and invite token lifetimes went with the tokens.
|
|
type Config struct {
|
|
Root RootConfig `mapstructure:"root"`
|
|
}
|
|
|
|
// RootConfig seeds the one row that impersonationidentn resolves to in local
|
|
// single-user mode. It carries NO password: nothing authenticates against this
|
|
// row — impersonation matches every request unconditionally, which is why
|
|
// identn::impersonation refuses to boot alongside any real resolver.
|
|
type RootConfig struct {
|
|
Enabled bool `mapstructure:"enabled"`
|
|
Email valuer.Email `mapstructure:"email"`
|
|
Org OrgConfig `mapstructure:"org"`
|
|
}
|
|
|
|
type OrgConfig struct {
|
|
ID valuer.UUID `mapstructure:"id"`
|
|
Name string `mapstructure:"name"`
|
|
}
|
|
|
|
func NewConfigFactory() factory.ConfigFactory {
|
|
return factory.NewConfigFactory(factory.MustNewName("user"), newConfig)
|
|
}
|
|
|
|
func newConfig() factory.Config {
|
|
return &Config{
|
|
Root: RootConfig{
|
|
Enabled: false,
|
|
Org: OrgConfig{
|
|
Name: "default",
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func (c Config) Validate() error {
|
|
if c.Root.Enabled && c.Root.Email.IsZero() {
|
|
return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "user::root::email is required when root user is enabled")
|
|
}
|
|
|
|
return nil
|
|
}
|