internal/boundary: add GetResourceType to Resource
The resource type method is used to automatically create refresh tokens from a resource when that resource is the last item returned in a page. This also renames the iam domain ResourceType method to GetResourceType to align with the new method.
This commit is contained in:
1 parent
5cded25c8d
commit
0d39456418
36 files changed
+184
-21
No files matched your search
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/auth/ldap/store"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -120,6 +121,11 @@ func (a *Account) GetSubject() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the Account
|
||||
func (a *Account) GetResourceType() resource.Type {
|
||||
return resource.Account
|
||||
}
|
||||
|
||||
// oplog will create oplog metadata for the Account.
|
||||
func (a *Account) oplog(ctx context.Context, opType oplog.OpType) (oplog.Metadata, error) {
|
||||
const op = "ldap.(Account).oplog"
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/auth/ldap/store"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -112,6 +113,11 @@ func (am *AuthMethod) SetTableName(n string) {
|
||||
am.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the AuthMethod
|
||||
func (am *AuthMethod) GetResourceType() resource.Type {
|
||||
return resource.AuthMethod
|
||||
}
|
||||
|
||||
// oplog will create oplog metadata for the AuthMethod.
|
||||
func (am *AuthMethod) oplog(ctx context.Context, opType oplog.OpType) (oplog.Metadata, error) {
|
||||
const op = "ldap.(AuthMethod).oplog"
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/auth/ldap/store"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -80,6 +81,11 @@ func (mg *ManagedGroup) SetTableName(n string) {
|
||||
mg.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the ManagedGroup
|
||||
func (mg *ManagedGroup) GetResourceType() resource.Type {
|
||||
return resource.ManagedGroup
|
||||
}
|
||||
|
||||
// oplog will create oplog metadata for the ManagedGroup.
|
||||
func (mg *ManagedGroup) oplog(ctx context.Context, opType oplog.OpType, authMethodScopeId string) (oplog.Metadata, error) {
|
||||
const op = "ldap.(ManagedGroup).oplog"
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc/store"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -115,6 +116,11 @@ func (a *Account) SetTableName(n string) {
|
||||
a.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the Account
|
||||
func (a *Account) GetResourceType() resource.Type {
|
||||
return resource.Account
|
||||
}
|
||||
|
||||
// GetLoginName returns the login name, which will always be empty as this type
|
||||
// doesn't currently support login name
|
||||
func (a *Account) GetLoginName() string {
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/libs/crypto"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"github.com/hashicorp/go-kms-wrapping/v2/extras/structwrapping"
|
||||
kvbuilder "github.com/hashicorp/go-secure-stdlib/kv-builder"
|
||||
@@ -196,6 +197,11 @@ func (a *AuthMethod) SetTableName(n string) {
|
||||
a.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the AuthMethod
|
||||
func (a *AuthMethod) GetResourceType() resource.Type {
|
||||
return resource.AuthMethod
|
||||
}
|
||||
|
||||
// oplog will create oplog metadata for the AuthMethod.
|
||||
func (a *AuthMethod) oplog(op oplog.OpType) oplog.Metadata {
|
||||
metadata := oplog.Metadata{
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc/store"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/go-bexpr"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@@ -86,6 +87,11 @@ func (mg *ManagedGroup) SetTableName(n string) {
|
||||
mg.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the ManagedGroup
|
||||
func (mg *ManagedGroup) GetResourceType() resource.Type {
|
||||
return resource.ManagedGroup
|
||||
}
|
||||
|
||||
// oplog will create oplog metadata for the ManagedGroup.
|
||||
func (mg *ManagedGroup) oplog(op oplog.OpType, authMethodScopeId string) oplog.Metadata {
|
||||
metadata := oplog.Metadata{
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/auth/password/store"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -70,6 +71,11 @@ func (a *Account) SetTableName(n string) {
|
||||
a.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the Account
|
||||
func (a *Account) GetResourceType() resource.Type {
|
||||
return resource.Account
|
||||
}
|
||||
|
||||
// GetEmail returns the email, which will always be empty as this type doesn't
|
||||
// currently support email
|
||||
func (a *Account) GetEmail() string {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/auth/password/store"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -69,6 +70,11 @@ func (a *AuthMethod) SetTableName(n string) {
|
||||
a.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the AuthMethod
|
||||
func (a *AuthMethod) GetResourceType() resource.Type {
|
||||
return resource.AuthMethod
|
||||
}
|
||||
|
||||
func (a *AuthMethod) oplog(op oplog.OpType) oplog.Metadata {
|
||||
metadata := oplog.Metadata{
|
||||
"resource-public-id": []string{a.GetPublicId()},
|
||||
|
||||
Reference in new issue
Block a user