* Allow repo packages to register subtypes and id prefixes. * Refactor out request authentication logic to a new package as a sibling to handler.
42 lines
1006 B
Go
42 lines
1006 B
Go
package password
|
|
|
|
import (
|
|
"github.com/hashicorp/boundary/internal/auth"
|
|
"github.com/hashicorp/boundary/internal/db"
|
|
"github.com/hashicorp/boundary/internal/errors"
|
|
"github.com/hashicorp/boundary/internal/intglobals"
|
|
"github.com/hashicorp/boundary/internal/types/subtypes"
|
|
)
|
|
|
|
|
|
func init() {
|
|
if err := auth.Register(Subtype, AuthMethodPrefix, intglobals.OldPasswordAccountPrefix, intglobals.NewPasswordAccountPrefix); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// PublicId prefixes for the resources in the password package.
|
|
const (
|
|
AuthMethodPrefix = "ampw"
|
|
|
|
Subtype = subtypes.Subtype("password")
|
|
)
|
|
|
|
func newAuthMethodId() (string, error) {
|
|
const op = "password.newAuthMethodId"
|
|
id, err := db.NewPublicId(AuthMethodPrefix)
|
|
if err != nil {
|
|
return "", errors.Wrap(err, op)
|
|
}
|
|
return id, nil
|
|
}
|
|
|
|
func newAccountId() (string, error) {
|
|
const op = "password.newAccountId"
|
|
id, err := db.NewPublicId(intglobals.NewPasswordAccountPrefix)
|
|
if err != nil {
|
|
return "", errors.Wrap(err, op)
|
|
}
|
|
return id, nil
|
|
}
|