mirror of
https://github.com/hanzoai/iam.git
synced 2026-11-19 18:37:16 +00:00
This repo is public and its LICENSE called the source "confidential and
proprietary ... All rights reserved". Public visibility contradicts
confidentiality, and HIP-0130 puts `iam` in the OSS core tier. The declaration
now matches both.
LICENSE-APACHE and LICENSE-MIT carry the canonical texts, unedited —
LICENSE-APACHE is byte-identical to apache.org/licenses/LICENSE-2.0.txt
(sha256 cfc7749b…, 11358 bytes, blob d645695). LICENSE declares the pair.
LICENSE-MIT carries the copyright line the notice requires.
249 Go files led with `// Copyright 2026 Hanzo AI, Inc. All rights reserved.`
— the classic proprietary reservation, and a per-file contradiction of the new
grant. Each now carries `// SPDX-License-Identifier: MIT OR Apache-2.0`. The
word "confidential" survives untouched in the OIDC sense (confidential client),
which is protocol vocabulary, not a licence claim.
There is nothing else to declare: `go.mod` has no licence field and this repo
ships no Cargo/npm/PyPI manifest.
Relicensing is ours alone to do. The tree is original work, not a fork:
`fork: false` with no parent, its own root commit, and no Casdoor-lineage tag
is an ancestor of `main`. The retired Casdoor fork is `hanzoai/iam-v1`; the
provenance note in LICENSE names it, restoring the vendor name a clean-room
assertion needs in order to say what it is clean of.
Build, vet and all 29 test packages green.
Co-authored-by: Hanzo Dev <[email protected]>
54 lines
2.1 KiB
Go
54 lines
2.1 KiB
Go
// Copyright 2026 Hanzo AI, Inc.
|
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
|
|
package store
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/hanzoai/orm"
|
|
|
|
"github.com/hanzoai/iam/pkg/model"
|
|
)
|
|
|
|
// GetMailableUsers lists the users of ONE organization that a non-transactional
|
|
// sender (a product announcement, a marketing drip) may lawfully and usefully
|
|
// reach: not deleted, not forbidden, and carrying an address. It is the customer
|
|
// ROSTER — an embedder resolves an audience against this instead of keeping a
|
|
// contact list of its own, so IAM stays the one source of truth for who a
|
|
// customer is and there is no second copy to drift.
|
|
//
|
|
// READ-ONLY BY CONSTRUCTION. There is no user write in this package: a sender
|
|
// must never mutate an identity. Rows come back MASKED (schema.User.Mask, the ONE
|
|
// redaction contract), so the password digest, access secret, TOTP seed and bearer
|
|
// material never cross the embed seam even in-process.
|
|
//
|
|
// org is REQUIRED — unlike GetProjects, an empty owner is refused rather than
|
|
// treated as the unscoped admin view. Owner IS the tenant, so an empty filter
|
|
// would return every user of every organization; on this path that is a
|
|
// cross-tenant mailing, not a listing. Fail closed instead.
|
|
//
|
|
// The deleted/forbidden/address predicates are applied in Go, not pushed into the
|
|
// query, BECAUSE the flags are `omitempty`: a false value is absent from the
|
|
// stored JSON document entirely, so a store-side `isDeleted = false` filter would
|
|
// match no row and the roster would come back empty. Only the owner filter —
|
|
// the tenancy key, always present and indexed — is pushed down.
|
|
func GetMailableUsers(db orm.DB, org string) ([]*model.User, error) {
|
|
if org == "" {
|
|
return nil, errors.New("iam store: organization is required")
|
|
}
|
|
rows, err := orm.TypedQuery[model.User](db).Filter("owner", org).Order("name").GetAll(context.Background())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out := make([]*model.User, 0, len(rows))
|
|
for _, u := range rows {
|
|
if u == nil || u.IsDeleted || u.IsForbidden || u.Email == "" {
|
|
continue
|
|
}
|
|
out = append(out, u.Mask())
|
|
}
|
|
return out, nil
|
|
}
|