Files
base/migrations/1789100100_rotate_superuser_tokens.go
zeekayandHanzo Dev 007a8c8002 Superuser tokens come only from IAM
A migration replaces the _superusers token secrets once, so every
superuser token a Base signed itself stops verifying on the first
start. auth-refresh answers 403 for a superuser token that names no IAM
subject, and answers an IAM token as before.

The test data records the rotation as applied, so its tokens stand for
tokens signed after it.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-11 13:58:52 -07:00

19 lines
476 B
Go

package migrations
import "github.com/hanzoai/base/core"
// Superuser tokens come from IAM. Replacing the secrets a Base signs superuser
// tokens with ends every superuser token a Base signed itself.
func init() {
core.SystemMigrations.Register(func(txApp core.App) error {
superusers, err := txApp.FindCollectionByNameOrId(core.CollectionNameSuperusers)
if err != nil {
return err
}
superusers.RotateTokenSecrets()
return txApp.Save(superusers)
}, nil)
}