* feat: Add support for capturing URL actions in request info
- Pass request context to services to validate actions.
- Validate actions for auth methods during authentication. `/v1/auth-methods/{{AUTH_METHOD_ID}}:authenticate:callback` is currently only supported on `OIDC` auth methods. An error is thrown if `:callback` is not supported
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package auth
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hashicorp/boundary/globals"
|
|
"github.com/hashicorp/boundary/internal/daemon/controller/common"
|
|
authpb "github.com/hashicorp/boundary/internal/gen/controller/auth"
|
|
"github.com/hashicorp/boundary/internal/requests"
|
|
)
|
|
|
|
// DisabledAuthTestContext is meant for testing, and uses a context that has
|
|
// auth checking entirely disabled. Supported options: WithScopeId an WithUserId
|
|
// are used directly; WithKms is passed through into the verifier context.
|
|
func DisabledAuthTestContext(iamRepoFn common.IamRepoFactory, scopeId string, opt ...Option) context.Context {
|
|
reqInfo := authpb.RequestInfo{DisableAuthEntirely: true}
|
|
opts := getOpts(opt...)
|
|
reqInfo.ScopeIdOverride = opts.withScopeId
|
|
if reqInfo.ScopeIdOverride == "" {
|
|
reqInfo.ScopeIdOverride = scopeId
|
|
}
|
|
reqInfo.UserIdOverride = opts.withUserId
|
|
if reqInfo.UserIdOverride == "" {
|
|
reqInfo.UserIdOverride = globals.AnyAuthenticatedUserId
|
|
}
|
|
reqInfo.Actions = opts.withActions
|
|
requestContext := context.WithValue(context.Background(), requests.ContextRequestInformationKey, &requests.RequestContext{})
|
|
return NewVerifierContext(requestContext, iamRepoFn, nil, nil, opts.withKms, &reqInfo)
|
|
}
|