Skip to content

v33: Config Makeover #593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2ba0bf4
config v3
gertd Dec 16, 2024
80215ed
config.yaml
gertd Dec 16, 2024
342b7c0
safepoint 20241216
gertd Dec 17, 2024
5a4c812
safepoint 20241216
gertd Dec 17, 2024
ba99fb0
savepoint 20241219
gertd Dec 19, 2024
8d33e4f
wip 20241231
gertd Dec 31, 2024
392b52a
merge main
gertd Dec 31, 2024
65d4d81
upd deps
gertd Dec 31, 2024
278845a
wip-20250105
gertd Jan 5, 2025
197ce42
Merge remote-tracking branch 'origin/main' into config
ronenh Apr 10, 2025
75471c1
Merge remote-tracking branch 'origin/main' into config
ronenh Apr 11, 2025
405cfc8
Use mapstructure decode hook for plugin config
ronenh Apr 14, 2025
8578919
side-by-side plugin config
ronenh Apr 15, 2025
7544a02
Move directory out of config and add pkg/topaz
ronenh Apr 15, 2025
055cbf7
Decision logger config
ronenh Apr 15, 2025
278bc50
Authorizer config
ronenh Apr 16, 2025
6f54abe
Services config validation
ronenh Apr 17, 2025
0a7be0d
topazd no longer generates dev certs.
ronenh Apr 17, 2025
52f3052
Most tests run without TLS
ronenh Apr 21, 2025
b253814
Merge remote-tracking branch 'origin/main' into config
ronenh Apr 21, 2025
656cb87
Fix CI
ronenh Apr 21, 2025
9e967c8
Move authentication middleware + initial svc builder
ronenh Apr 30, 2025
dbfd1d6
grpc + gateway builder
ronenh May 2, 2025
8171058
Move config to pkg/topaz/config
ronenh May 2, 2025
b6ebedf
Cleanup server builder
ronenh May 5, 2025
54658c6
Register grpc reflection service
ronenh May 5, 2025
4d9aaa3
Authorizer resolvers cleanup. Service can start/stop.
ronenh May 6, 2025
af2d51f
Merge remote-tracking branch 'origin/main' into config
ronenh May 8, 2025
c5366c0
Services can accept connections
ronenh May 15, 2025
ad772c9
All tests pass
ronenh May 15, 2025
1f80402
No policy-instance middleware
ronenh May 15, 2025
45525f4
Merge remote-tracking branch 'origin/main' into config
ronenh May 15, 2025
c37f35b
Initial console wiring
ronenh May 16, 2025
ccb51df
Switch to vault.aserto.com
ronenh May 16, 2025
a1024da
Use new topaz console
ronenh May 19, 2025
6dae334
Initial cleanup of code no longer used
ronenh May 19, 2025
4797513
Set service health status
ronenh May 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: ci

on:
Expand All @@ -7,17 +8,14 @@ on:
# Publish `main` as Docker `latest` image.
branches:
- main
- dev
- dev-*
- release-*
# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for all PRs
pull_request:

env:
VAULT_ADDR: https://vault.eng.aserto.com/
VAULT_ADDR: https://vault.aserto.com/
PRE_RELEASE: ${{ github.ref == 'refs/heads/main' && 'main' || '' }}
GO_VERSION: "1.24"
GO_RELEASER_VERSION: "v2.8.2"
Expand All @@ -34,7 +32,7 @@ jobs:
uses: hashicorp/vault-action@v3
id: vault
with:
url: https://vault.eng.aserto.com/
url: ${{ env.VAULT_ADDR }}
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
kv/data/github "SSH_PRIVATE_KEY" | SSH_PRIVATE_KEY;
Expand Down Expand Up @@ -84,6 +82,16 @@ jobs:
with:
version: ${{ env.GO_LANGCI_LINT_VERSION }}
args: --timeout=30m
-
name: Test Setup
uses: gertd/action-gotestsum@v3.0.0
with:
gotestsum_version: ${{ env.GO_TESTSUM_VERSION }}
-
name: Unit Test
run: |
gotestsum --format short-verbose -- $(go list ./... | grep -v pkg/app/tests) \
-count=1 -timeout 120s -parallel=1 -v
-
name: Test Snapshot
uses: goreleaser/goreleaser-action@v6
Expand All @@ -93,28 +101,21 @@ jobs:
distribution: goreleaser
version: ${{ env.GO_RELEASER_VERSION }}
args: release --clean --snapshot --config .goreleaser-test.yml
-
name: Test Setup
uses: gertd/action-gotestsum@v3.0.0
with:
gotestsum_version: ${{ env.GO_TESTSUM_VERSION }}
-
name: Test
run: |
gotestsum --format short-verbose -- -count=1 -timeout 120s -parallel=1 -v -coverprofile=cover.out -coverpkg=github.com/aserto-dev/topaz/pkg/app/tests/authz/... github.com/aserto-dev/topaz/pkg/app/tests/authz/...
gotestsum --format short-verbose -- -count=1 -timeout 120s -parallel=1 -v -coverprofile=cover.out -coverpkg=github.com/aserto-dev/topaz/pkg/app/tests/builtin/... github.com/aserto-dev/topaz/pkg/app/tests/builtin/...
gotestsum --format short-verbose -- -count=1 -timeout 120s -parallel=1 -v -coverprofile=cover.out -coverpkg=github.com/aserto-dev/topaz/pkg/app/tests/ds/... github.com/aserto-dev/topaz/pkg/app/tests/ds/...
gotestsum --format short-verbose -- -count=1 -timeout 120s -parallel=1 -v -coverprofile=cover.out -coverpkg=github.com/aserto-dev/topaz/pkg/app/tests/manifest/... github.com/aserto-dev/topaz/pkg/app/tests/manifest/...
gotestsum --format short-verbose -- -count=1 -timeout 120s -parallel=1 -v -coverprofile=cover.out -coverpkg=github.com/aserto-dev/topaz/pkg/app/tests/policy/... github.com/aserto-dev/topaz/pkg/app/tests/policy/...
gotestsum --format short-verbose -- -count=1 -timeout 120s -parallel=1 -v -coverprofile=cover.out -coverpkg=github.com/aserto-dev/topaz/pkg/app/tests/query/... github.com/aserto-dev/topaz/pkg/app/tests/query/...
gotestsum --format short-verbose -- $(go list ./pkg/app/tests/... | grep -v tests/template) \
-count=1 -timeout 120s -parallel=1 -v
-
name: Templates Test
run: |
gotestsum --format short-verbose -- -count=1 -timeout 240s -parallel=1 -v -coverprofile=cover.out -coverpkg=github.com/aserto-dev/topaz/pkg/app/tests/template/... github.com/aserto-dev/topaz/pkg/app/tests/template/...
gotestsum --format short-verbose -- github.com/aserto-dev/topaz/pkg/app/tests/template/... \
-count=1 -timeout 240s -parallel=1 -v
-
name: Templates Test (NoTLS)
name: Templates Test (With TLS)
run: |
gotestsum --format short-verbose -- -count=1 -timeout 120s -parallel=1 -v -coverprofile=cover.out -coverpkg=github.com/aserto-dev/topaz/pkg/app/tests/template-no-tls/... github.com/aserto-dev/topaz/pkg/app/tests/template-no-tls/...
gotestsum --format short-verbose -- github.com/aserto-dev/topaz/pkg/app/tests/template-with-tls/... \
-count=1 -timeout 120s -parallel=1 -v
-
name: Upload code coverage
uses: shogo82148/actions-goveralls@v1
Expand All @@ -126,14 +127,14 @@ jobs:
runs-on: ubuntu-latest
# when on a branch only push if the branch is main
# always push when ref is a tag
if: github.event_name == 'push' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/heads/dev-') || startsWith(github.ref, 'refs/tags/v') )
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
steps:
-
name: Read Configuration
uses: hashicorp/vault-action@v3
id: vault
with:
url: https://vault.eng.aserto.com/
url: ${{ env.VAULT_ADDR }}
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
kv/data/github "SSH_PRIVATE_KEY" | SSH_PRIVATE_KEY;
Expand Down Expand Up @@ -208,7 +209,7 @@ jobs:
uses: hashicorp/vault-action@v3
id: vault
with:
url: https://vault.eng.aserto.com/
url: ${{ env.VAULT_ADDR }}
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
kv/data/github "SSH_PRIVATE_KEY" | SSH_PRIVATE_KEY;
Expand Down Expand Up @@ -261,11 +262,11 @@ jobs:
distribution: goreleaser
version: ${{ env.GO_RELEASER_VERSION }}
args: release --clean
-
-
name: Archive deployment examples
run: |
cd docs/deployments/sidecar-deployment && zip topaz_deployment_examples.zip *.yaml
-
-
name: Upload deployment examples
uses: svenstaro/upload-release-action@v2
with:
Expand All @@ -279,12 +280,12 @@ jobs:
needs: release
runs-on: windows-latest
steps:
-
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
-
name: Read Configuration
uses: hashicorp/vault-action@v3
id: vault
Expand All @@ -293,7 +294,7 @@ jobs:
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
kv/data/github "ROOT_TOKEN" | ROOT_TOKEN;
-
-
name: Download exe
id: download_exe
shell: bash
Expand All @@ -303,16 +304,16 @@ jobs:
unzip -o *.zip && rm -v *.zip
env:
GITHUB_TOKEN: ${{ steps.vault.outputs.ROOT_TOKEN }}
-
-
name: Install go-msi
run: choco install -y "go-msi"
-
-
name: Prepare PATH
shell: bash
run: |
echo "$WIX\\bin" >> $GITHUB_PATH
echo "C:\\Program Files\\go-msi" >> $GITHUB_PATH
-
-
name: Build MSI
id: buildmsi
shell: bash
Expand All @@ -323,7 +324,7 @@ jobs:
msi="$(basename "$ZIP_FILE" ".zip").msi"
printf "msi=${msi}" >> $GITHUB_OUTPUT
go-msi make --arch amd64 --msi "$PWD/$msi" --out "$PWD/build" --version "${GITHUB_REF#refs/tags/}"
-
-
name: Upload MSI
shell: bash
run: |
Expand Down
10 changes: 6 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ linters:
- stdlib
- generic
- proto.Message
- http.Handler
- grpc.DialOption
- grpc.ServerOption
- plugins.Plugin
- decisionlog.DecisionLogger
- resolvers.DirectoryResolver
- resolvers.RuntimeResolver
- v3.ReaderClient

lll:
line-length: 150
Expand All @@ -80,6 +79,9 @@ linters:
yaml: snake

overrides:
- pkg: pkg/console
rules:
json: camel
- pkg: pkg/app/handlers
rules:
json: camel
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN mkdir /config && \
mkdir /certs && \
mkdir /db && \
mkdir /decisions
VOLUME ["/config", "/certs", "/db", "/decisions"]
VOLUME ["/config", "/db", "/decisions"]

WORKDIR /app

Expand Down
101 changes: 2 additions & 99 deletions builtins/edge/ds/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ds

import (
dsr3 "github.com/aserto-dev/go-directory/aserto/directory/reader/v3"
"github.com/aserto-dev/topaz/resolvers"

"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/rego"
Expand All @@ -22,7 +21,7 @@ import (
// "subject_id": "",
// "trace": false
// })
func RegisterCheck(logger *zerolog.Logger, fnName string, dr resolvers.DirectoryResolver) (*rego.Function, rego.Builtin1) {
func RegisterCheck(logger *zerolog.Logger, fnName string, dr dsr3.ReaderClient) (*rego.Function, rego.Builtin1) {
return &rego.Function{
Name: fnName,
Decl: types.NewFunction(types.Args(types.A), types.B),
Expand All @@ -45,103 +44,7 @@ func RegisterCheck(logger *zerolog.Logger, fnName string, dr resolvers.Directory
})
}

resp, err := dr.GetDS().Check(bctx.Context, &args)
if err != nil {
traceError(&bctx, fnName, err)
return nil, err
}

return ast.BooleanTerm(resp.GetCheck()), nil
}
}

// RegisterCheckRelation - ds.check_relation
//
// ds.check_relation: {
// "object_id": "",
// "object_type": "",
// "relation": "",
// "subject_id": "",
// "subject_type": "",
// "trace": false
// }
//
//nolint:dupl // RegisterCheck[Relation|Permission] are not identical, obsolete and will be removed in v33.
func RegisterCheckRelation(logger *zerolog.Logger, fnName string, dr resolvers.DirectoryResolver) (*rego.Function, rego.Builtin1) {
return &rego.Function{
Name: fnName,
Decl: types.NewFunction(types.Args(types.A), types.B),
Memoize: true,
},
func(bctx rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) {
var args dsr3.CheckRelationRequest

if err := ast.As(op1.Value, &args); err != nil {
traceError(&bctx, fnName, err)
return nil, err
}

if proto.Equal(&args, &dsr3.CheckRelationRequest{}) {
return helpMsg(fnName, &dsr3.CheckRelationRequest{
ObjectType: "",
ObjectId: "",
Relation: "",
SubjectType: "",
SubjectId: "",
Trace: false,
})
}

//nolint: staticcheck // SA1019: client.CheckRelation is deprecated
resp, err := dr.GetDS().CheckRelation(bctx.Context, &args)
if err != nil {
traceError(&bctx, fnName, err)
return nil, err
}

return ast.BooleanTerm(resp.GetCheck()), nil
}
}

// RegisterCheckPermission - ds.check_permission
//
// ds.check_permission: {
// "object_id": "",
// "object_type": "",
// "permission": "",
// "subject_id": "",
// "subject_type": "",
// "trace": false
// }
//
//nolint:dupl // RegisterCheck[Relation|Permission] are not identical, obsolete and will be removed in v33.
func RegisterCheckPermission(logger *zerolog.Logger, fnName string, dr resolvers.DirectoryResolver) (*rego.Function, rego.Builtin1) {
return &rego.Function{
Name: fnName,
Decl: types.NewFunction(types.Args(types.A), types.B),
Memoize: true,
},
func(bctx rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) {
var args dsr3.CheckPermissionRequest

if err := ast.As(op1.Value, &args); err != nil {
traceError(&bctx, fnName, err)
return nil, err
}

if proto.Equal(&args, &dsr3.CheckPermissionRequest{}) {
return helpMsg(fnName, &dsr3.CheckPermissionRequest{
ObjectType: "",
ObjectId: "",
Permission: "",
SubjectType: "",
SubjectId: "",
Trace: false,
})
}

//nolint: staticcheck // SA1019: client.CheckPermission is deprecated
resp, err := dr.GetDS().CheckPermission(bctx.Context, &args)
resp, err := dr.Check(bctx.Context, &args)
if err != nil {
traceError(&bctx, fnName, err)
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions builtins/edge/ds/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"

dsr3 "github.com/aserto-dev/go-directory/aserto/directory/reader/v3"
"github.com/aserto-dev/topaz/resolvers"

"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/rego"
Expand All @@ -28,7 +27,7 @@ import (
// "subject_id": "",
// "trace": false
// })
func RegisterChecks(logger *zerolog.Logger, fnName string, dr resolvers.DirectoryResolver) (*rego.Function, rego.Builtin1) {
func RegisterChecks(logger *zerolog.Logger, fnName string, dr dsr3.ReaderClient) (*rego.Function, rego.Builtin1) {
return &rego.Function{
Name: fnName,
Decl: types.NewFunction(types.Args(types.A), types.A),
Expand Down Expand Up @@ -70,7 +69,7 @@ func RegisterChecks(logger *zerolog.Logger, fnName string, dr resolvers.Director
args.Checks = []*dsr3.CheckRequest{}
}

resp, err := dr.GetDS().Checks(bctx.Context, &args)
resp, err := dr.Checks(bctx.Context, &args)
if err != nil {
traceError(&bctx, fnName, err)
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions builtins/edge/ds/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"

dsr3 "github.com/aserto-dev/go-directory/aserto/directory/reader/v3"
"github.com/aserto-dev/topaz/resolvers"

"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/rego"
Expand All @@ -26,7 +25,7 @@ import (
// "explain": false,
// "trace": false
// }
func RegisterGraph(logger *zerolog.Logger, fnName string, dr resolvers.DirectoryResolver) (*rego.Function, rego.Builtin1) {
func RegisterGraph(logger *zerolog.Logger, fnName string, dr dsr3.ReaderClient) (*rego.Function, rego.Builtin1) {
return &rego.Function{
Name: fnName,
Decl: types.NewFunction(types.Args(types.A), types.A),
Expand All @@ -53,7 +52,7 @@ func RegisterGraph(logger *zerolog.Logger, fnName string, dr resolvers.Directory
})
}

resp, err := dr.GetDS().GetGraph(bctx.Context, &args)
resp, err := dr.GetGraph(bctx.Context, &args)
if err != nil {
traceError(&bctx, fnName, err)
return nil, err
Expand Down
Loading
Loading