2020-07-24 10:23:35 -04:00
|
|
|
package password
|
|
|
|
|
|
|
|
|
|
import (
|
2022-04-08 11:40:59 -04:00
|
|
|
"github.com/hashicorp/boundary/internal/auth"
|
2020-08-10 17:15:02 -04:00
|
|
|
"github.com/hashicorp/boundary/internal/db"
|
2021-02-11 13:32:45 -06:00
|
|
|
"github.com/hashicorp/boundary/internal/errors"
|
2021-06-08 11:31:58 -05:00
|
|
|
"github.com/hashicorp/boundary/internal/intglobals"
|
2021-07-27 09:59:52 -07:00
|
|
|
"github.com/hashicorp/boundary/internal/types/subtypes"
|
2020-07-24 10:23:35 -04:00
|
|
|
)
|
|
|
|
|
|
2021-07-27 09:59:52 -07:00
|
|
|
func init() {
|
2022-04-08 11:40:59 -04:00
|
|
|
if err := subtypes.Register(auth.Domain, Subtype, AuthMethodPrefix, intglobals.OldPasswordAccountPrefix, intglobals.NewPasswordAccountPrefix); err != nil {
|
2021-07-27 09:59:52 -07:00
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 10:23:35 -04:00
|
|
|
// PublicId prefixes for the resources in the password package.
|
|
|
|
|
const (
|
2020-08-25 00:21:08 -04:00
|
|
|
AuthMethodPrefix = "ampw"
|
2021-07-27 09:59:52 -07:00
|
|
|
|
|
|
|
|
Subtype = subtypes.Subtype("password")
|
2020-07-24 10:23:35 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func newAuthMethodId() (string, error) {
|
2021-02-11 13:32:45 -06:00
|
|
|
const op = "password.newAuthMethodId"
|
2020-07-24 10:23:35 -04:00
|
|
|
id, err := db.NewPublicId(AuthMethodPrefix)
|
|
|
|
|
if err != nil {
|
2021-07-29 18:52:56 -06:00
|
|
|
return "", errors.WrapDeprecated(err, op)
|
2020-07-24 10:23:35 -04:00
|
|
|
}
|
2021-03-05 06:34:06 -08:00
|
|
|
return id, nil
|
2020-07-24 10:23:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newAccountId() (string, error) {
|
2021-02-11 13:32:45 -06:00
|
|
|
const op = "password.newAccountId"
|
2021-06-08 11:31:58 -05:00
|
|
|
id, err := db.NewPublicId(intglobals.NewPasswordAccountPrefix)
|
2020-07-24 10:23:35 -04:00
|
|
|
if err != nil {
|
2021-07-29 18:52:56 -06:00
|
|
|
return "", errors.WrapDeprecated(err, op)
|
2020-07-24 10:23:35 -04:00
|
|
|
}
|
2021-03-05 06:34:06 -08:00
|
|
|
return id, nil
|
2020-07-24 10:23:35 -04:00
|
|
|
}
|