Create Alias Domain Object and Repo (#4275)

* Create alias domain object resource

* Add paginated listing

* fixing ratelimit related panics

* Address reviewer comments

* remove NewAlias value checks
This commit is contained in:
Todd committed 2024-02-29 15:51:24 -08:00
1 parent 7e2038bfcc
commit e848e76b48
38 files changed
+3787 -5

No files matched your search

@@ -0,0 +1,32 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package aliases
import (
"github.com/hashicorp/boundary/internal/types/action"
"github.com/hashicorp/boundary/internal/types/resource"
)
var (
// IdActions contains the set of actions that can be performed on
// individual resources
IdActions = action.NewActionSet(
action.NoOp,
action.Read,
action.Update,
action.Delete,
)
// CollectionActions contains the set of actions that can be performed on
// this collection
CollectionActions = action.NewActionSet(
action.Create,
action.List,
)
)
func init() {
// TODO: refactor to remove idActionsMap and CollectionActions package variables
action.RegisterResource(resource.Alias, action.Union(IdActions), CollectionActions)
}
@@ -14,6 +14,7 @@ import (
"github.com/hashicorp/boundary/internal/daemon/controller/common"
"github.com/hashicorp/boundary/internal/daemon/controller/common/scopeids"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/aliases"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/authmethods"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/authtokens"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/credentialstores"
@@ -76,6 +77,7 @@ var (
// TODO: get this from action registry
scopeCollectionTypeMapMap = map[string]map[resource.Type]action.ActionSet{
scope.Global.String(): {
resource.Alias: aliases.CollectionActions,
resource.AuthMethod: authmethods.CollectionActions,
resource.StorageBucket: storage_buckets.CollectionActions,
resource.AuthToken: authtokens.CollectionActions,
@@ -81,6 +81,12 @@ func createDefaultScopesRepoAndKms(t *testing.T) (*iam.Scope, *iam.Scope, func()
}
var globalAuthorizedCollectionActions = map[string]*structpb.ListValue{
"aliases": {
Values: []*structpb.Value{
structpb.NewStringValue("create"),
structpb.NewStringValue("list"),
},
},
"auth-methods": {
Values: []*structpb.Value{
structpb.NewStringValue("create"),
@@ -63,7 +63,7 @@ func Test_newRateLimiterConfig(t *testing.T) {
ratelimit.DefaultLimiterMaxQuotas(),
false,
&rateLimiterConfig{
maxSize: 324162,
maxSize: 336168,
configs: nil,
disabled: false,
limits: defaultLimits,
@@ -6,6 +6,164 @@
"data": {
"data": {
"limits": {
"alias": {
"create": [
{
"action": "create",
"limit": 30000,
"per": "ip-address",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "create",
"limit": 30000,
"per": "total",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "create",
"limit": 3000,
"per": "auth-token",
"period": "30s",
"resource": "alias",
"unlimited": false
}
],
"delete": [
{
"action": "delete",
"limit": 30000,
"per": "total",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "delete",
"limit": 30000,
"per": "ip-address",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "delete",
"limit": 3000,
"per": "auth-token",
"period": "30s",
"resource": "alias",
"unlimited": false
}
],
"list": [
{
"action": "list",
"limit": 150,
"per": "auth-token",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "list",
"limit": 1500,
"per": "total",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "list",
"limit": 1500,
"per": "ip-address",
"period": "30s",
"resource": "alias",
"unlimited": false
}
],
"no-op": [
{
"action": "no-op",
"limit": 3000,
"per": "auth-token",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "no-op",
"limit": 30000,
"per": "ip-address",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "no-op",
"limit": 30000,
"per": "total",
"period": "30s",
"resource": "alias",
"unlimited": false
}
],
"read": [
{
"action": "read",
"limit": 30000,
"per": "ip-address",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "read",
"limit": 3000,
"per": "auth-token",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "read",
"limit": 30000,
"per": "total",
"period": "30s",
"resource": "alias",
"unlimited": false
}
],
"update": [
{
"action": "update",
"limit": 3000,
"per": "auth-token",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "update",
"limit": 30000,
"per": "total",
"period": "30s",
"resource": "alias",
"unlimited": false
},
{
"action": "update",
"limit": 30000,
"per": "ip-address",
"period": "30s",
"resource": "alias",
"unlimited": false
}
]
},
"account": {
"change-password": [
{
@@ -4075,7 +4233,7 @@
]
}
},
"max_size": 324162,
"max_size": 336168,
"msg": "controller api rate limiter"
},
"op": "controller.(rateLimiterConfig).writeSysEvent",
@@ -4075,7 +4075,7 @@
]
}
},
"max_size": 324162,
"max_size": 336168,
"msg": "controller api rate limiter"
},
"op": "controller.(rateLimiterConfig).writeSysEvent",