2022-04-08 11:40:59 -04:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-02-02 17:15:17 -08:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2020-07-24 10:23:35 -04:00
|
|
|
package password
|
|
|
|
|
|
|
|
|
|
import (
|
2023-06-06 17:09:08 -04:00
|
|
|
"context"
|
|
|
|
|
|
2023-03-10 15:06:39 -05:00
|
|
|
"github.com/hashicorp/boundary/globals"
|
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"
|
2023-11-15 19:55:46 -05:00
|
|
|
"github.com/hashicorp/boundary/internal/types/resource"
|
2020-07-24 10:23:35 -04:00
|
|
|
)
|
|
|
|
|
|
2021-07-27 09:59:52 -07:00
|
|
|
func init() {
|
2023-11-15 19:55:46 -05:00
|
|
|
globals.RegisterPrefixToResourceInfo(globals.PasswordAuthMethodPrefix, resource.AuthMethod, auth.Domain, Subtype)
|
|
|
|
|
globals.RegisterPrefixToResourceInfo(globals.PasswordAccountPreviousPrefix, resource.Account, auth.Domain, Subtype)
|
|
|
|
|
globals.RegisterPrefixToResourceInfo(globals.PasswordAccountPrefix, resource.Account, auth.Domain, Subtype)
|
2021-07-27 09:59:52 -07:00
|
|
|
}
|
|
|
|
|
|
2023-11-02 16:03:47 -04:00
|
|
|
// PublicId prefixes for the resources in the password package.
|
|
|
|
|
const (
|
2023-11-15 19:55:46 -05:00
|
|
|
Subtype = globals.Subtype("password")
|
2023-11-02 16:03:47 -04:00
|
|
|
)
|
|
|
|
|
|
2023-06-06 17:09:08 -04:00
|
|
|
func newAuthMethodId(ctx context.Context) (string, error) {
|
2021-02-11 13:32:45 -06:00
|
|
|
const op = "password.newAuthMethodId"
|
2023-06-06 17:09:08 -04:00
|
|
|
id, err := db.NewPublicId(ctx, globals.PasswordAuthMethodPrefix)
|
2020-07-24 10:23:35 -04:00
|
|
|
if err != nil {
|
2023-06-06 17:09:08 -04:00
|
|
|
return "", errors.Wrap(ctx, 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
|
|
|
}
|
|
|
|
|
|
2023-06-06 17:09:08 -04:00
|
|
|
func newAccountId(ctx context.Context) (string, error) {
|
2021-02-11 13:32:45 -06:00
|
|
|
const op = "password.newAccountId"
|
2023-06-06 17:09:08 -04:00
|
|
|
id, err := db.NewPublicId(ctx, globals.PasswordAccountPrefix)
|
2020-07-24 10:23:35 -04:00
|
|
|
if err != nil {
|
2023-06-06 17:09:08 -04:00
|
|
|
return "", errors.Wrap(ctx, 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
|
|
|
}
|