Skip to content

Commit c49e330

Browse files
committed
upd buf, apply buf fmt
1 parent c775a64 commit c49e330

File tree

12 files changed

+384
-464
lines changed

12 files changed

+384
-464
lines changed

.envrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/build.yaml

Lines changed: 18 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ on:
99
tags:
1010
- 'v*.*.*'
1111
pull_request:
12+
types: [opened, synchronize, reopened, labeled, unlabeled]
1213
branches:
1314
- main
15+
delete:
16+
17+
permissions:
18+
contents: read
19+
pull-requests: write
20+
1421
env:
15-
VAULT_ADDR: https://vault.eng.aserto.com/
16-
BUF_VERSION: "1.34.0"
22+
BUF_VERSION: "1.61.0"
1723

1824
jobs:
1925
build:
@@ -25,51 +31,13 @@ jobs:
2531
with:
2632
fetch-depth: 0
2733
-
28-
name: Read Configuration
29-
uses: hashicorp/vault-action@v3
30-
id: vault
31-
with:
32-
url: ${{ env.VAULT_ADDR }}
33-
token: ${{ secrets.VAULT_TOKEN }}
34-
secrets: |
35-
kv/data/github "USERNAME" | GH_USERNAME;
36-
kv/data/github "READ_WRITE_TOKEN" | GH_TOKEN;
37-
kv/data/buf.build "ASERTO_BUF_USER" | ASERTO_BUF_USER;
38-
kv/data/buf.build "ASERTO_BUF_TOKEN" | ASERTO_BUF_TOKEN;
39-
-
40-
name: Install svu
41-
run: |
42-
echo 'deb [trusted=yes] https://apt.fury.io/caarlos0/ /' | sudo tee /etc/apt/sources.list.d/caarlos0.list
43-
sudo apt update
44-
sudo apt install svu
45-
svu --version
46-
svu
47-
-
48-
name: Install buf
49-
uses: bufbuild/buf-setup-action@v1
50-
with:
51-
version: ${{ env.BUF_VERSION }}
52-
github_token: ${{ github.token }}
53-
buf_user: ${{ steps.vault.outputs.ASERTO_BUF_USER }}
54-
buf_api_token: ${{ steps.vault.outputs.ASERTO_BUF_TOKEN}}
55-
-
56-
name: Buf Lint
57-
uses: bufbuild/buf-lint-action@v1
58-
-
59-
name: Buf Breaking
60-
uses: bufbuild/buf-breaking-action@v1
61-
with:
62-
against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=main"
63-
-
6434
name: Buf Build
65-
run: |
66-
mkdir -p ./bin
67-
buf build --output ./bin/directory.bin
68-
-
69-
name: Buf Push
70-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
71-
run: |
72-
buf push --label $(svu)
35+
uses: bufbuild/buf-action@v1
36+
with:
37+
version: ${{ env.BUF_VERSION }}
38+
token: ${{ secrets.ASERTO_BUF_TOKEN}}
39+
github_token: ${{ secrets.GITHUB_TOKEN}}
40+
push_disable_create: true
7341

7442
trigger-dispatches:
7543
runs-on: ubuntu-latest
@@ -80,27 +48,20 @@ jobs:
8048
cfg:
8149
- { project: go-authorizer }
8250
- { project: node-authorizer }
83-
- { project: ruby-authorizer }
8451
- { project: dotnet-authorizer }
52+
- { project: ruby-authorizer }
8553
- { project: python-authorizer }
8654
- { project: openapi-authorizer }
8755
- { project: java-authorizer }
8856

8957
name: Generate on ${{ matrix.cfg.project }}
9058
steps:
91-
-
92-
name: Read Configuration
93-
uses: hashicorp/vault-action@v3
94-
id: vault
95-
with:
96-
url: ${{ env.VAULT_ADDR }}
97-
token: ${{ secrets.VAULT_TOKEN }}
98-
secrets: |
99-
kv/data/github "USERNAME" | GH_USERNAME;
100-
kv/data/github "READ_WRITE_TOKEN" | GH_TOKEN;
10159
-
10260
name: Trigger dispatch
10361
run: |
10462
curl -XPOST -u "${GH_USERNAME}:${GH_TOKEN}" \
10563
-H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" \
10664
https://api.github.com/repos/aserto-dev/${{ matrix.cfg.project }}/actions/workflows/ci.yaml/dispatches --data '{"ref": "main", "inputs": {"proto_ref": "${{ github.ref }}", "proto_sha": "${{ github.sha }}" }}'
65+
env:
66+
GH_USERNAME: ${{ secrets.USERNAME }}
67+
GH_TOKEN: $${{ secrets.READ_WRITE_TOKEN }}

.github/workflows/gitleaks-check.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/gitleaks.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: gitleaks
2+
on:
3+
pull_request:
4+
push:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: "0 4 * * *" # run once a day at 4 AM
8+
jobs:
9+
scan:
10+
name: gitleaks
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
with:
15+
fetch-depth: 0
16+
- uses: gitleaks/gitleaks-action@v2
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}

buf.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ deps:
77
- buf.build/grpc-ecosystem/grpc-gateway
88
lint:
99
use:
10-
- DEFAULT
10+
- STANDARD
1111
except:
1212
- FIELD_NOT_REQUIRED
1313
- PACKAGE_DIRECTORY_MATCH

makefile

Lines changed: 50 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,57 @@
1-
SHELL := $(shell which bash)
2-
3-
NO_COLOR := \033[0m
4-
OK_COLOR := \033[32;01m
5-
ERR_COLOR := \033[31;01m
6-
WARN_COLOR := \033[36;01m
7-
ATTN_COLOR := \033[33;01m
8-
9-
GOOS := $(shell go env GOOS)
10-
GOARCH := $(shell go env GOARCH)
11-
GOPRIVATE := "github.com/aserto-dev"
12-
13-
BIN_DIR := ./bin
14-
EXT_DIR := ./.ext
15-
EXT_BIN_DIR := ${EXT_DIR}/bin
16-
EXT_TMP_DIR := ${EXT_DIR}/tmp
17-
18-
VAULT_VERSION := 1.8.12
19-
SVU_VERSION := 1.12.0
20-
WIRE_VERSION := 0.6.0
21-
BUF_VERSION := 1.34.0
22-
23-
PROJECT := authorizer
24-
BUF_USER := $(shell vault kv get -field ASERTO_BUF_USER kv/buf.build)
25-
BUF_TOKEN := $(shell vault kv get -field ASERTO_BUF_TOKEN kv/buf.build)
26-
BUF_REPO := "buf.build/aserto-dev/${PROJECT}"
27-
BUF_LATEST := $(shell BUF_BETA_SUPPRESS_WARNINGS=1 ${EXT_BIN_DIR}/buf beta registry label list ${BUF_REPO} --format json --reverse | jq -r '.results[0].name')
28-
BUF_DEV_IMAGE := "${PROJECT}.bin"
29-
PROTO_REPO := "pb-${PROJECT}"
30-
31-
GIT_ORG := "https://github.com/aserto-dev"
32-
33-
RELEASE_TAG := $$(svu)
1+
SHELL := $(shell which bash)
342

35-
.PHONY: deps
36-
deps: info install-vault install-buf install-svu
37-
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
3+
NO_COLOR := \033[0m
4+
OK_COLOR := \033[32;01m
5+
ERR_COLOR := \033[31;01m
6+
WARN_COLOR := \033[36;01m
7+
ATTN_COLOR := \033[33;01m
8+
9+
GOOS := $(shell go env GOOS)
10+
GOARCH := $(shell go env GOARCH)
11+
GOPRIVATE := "github.com/aserto-dev"
12+
13+
BIN_DIR := ${PWD}/bin
14+
EXT_DIR := ${PWD}/.ext
15+
EXT_BIN_DIR := ${EXT_DIR}/bin
16+
EXT_TMP_DIR := ${EXT_DIR}/tmp
17+
18+
SVU_VER := 3.3.0
19+
BUF_VER := 1.61.0
3820

39-
.PHONY: vault-login
40-
vault-login:
21+
PROJECT := authorizer
22+
BUF_REPO := "buf.build/aserto-dev/${PROJECT}"
23+
BUF_LATEST := $(shell ${EXT_BIN_DIR}/buf registry module label list ${BUF_REPO} --format json | jq -r '.labels[0].name')
24+
BUF_DEV_IMAGE := "${PROJECT}.bin"
25+
PROTO_REPO := "pb-${PROJECT}"
26+
GIT_ORG := "https://github.com/aserto-dev"
27+
28+
RELEASE_TAG := $$(${EXT_BIN_DIR}/svu current)
29+
30+
.DEFAULT_GOAL := buf-build
31+
32+
.PHONY: deps
33+
deps: info install-buf install-svu
4134
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
42-
@vault login -method=github token=$$(gh auth token)
4335

4436
.PHONY: buf-login
4537
buf-login:
4638
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
47-
@echo ${BUF_TOKEN} | ${EXT_BIN_DIR}/buf registry login --username ${BUF_USER} --token-stdin
39+
@echo ${BUF_TOKEN} | ${EXT_BIN_DIR}/buf registry login --token-stdin
40+
41+
.PHONY: buf-dep-update
42+
buf-dep-update:
43+
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
44+
@${EXT_BIN_DIR}/buf dep update
45+
46+
.PHONY: buf-format
47+
buf-format:
48+
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
49+
@${EXT_BIN_DIR}/buf format -w proto
50+
51+
.PHONY: buf-build
52+
buf-build: ${BIN_DIR}
53+
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
54+
@${EXT_BIN_DIR}/buf build --output ${BIN_DIR}/${BUF_DEV_IMAGE}
4855

4956
.PHONY: buf-lint
5057
buf-lint:
@@ -56,31 +63,11 @@ buf-breaking:
5663
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
5764
@${EXT_BIN_DIR}/buf breaking --against "${GIT_ORG}/${PROTO_REPO}.git#branch=main"
5865

59-
.PHONY: buf-build
60-
buf-build: ${BIN_DIR}
61-
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
62-
@${EXT_BIN_DIR}/buf build --output ${BIN_DIR}/${BUF_DEV_IMAGE}
63-
6466
.PHONY: buf-push
6567
buf-push:
6668
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
6769
@${EXT_BIN_DIR}/buf push --label ${RELEASE_TAG}
6870

69-
.PHONY: buf-dep-update
70-
buf-dep-update:
71-
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
72-
@${EXT_BIN_DIR}/buf dep update
73-
74-
.PHONY: buf-generate
75-
buf-generate:
76-
@echo -e "$(ATTN_COLOR)==> $@ ${BUF_REPO}:${BUF_LATEST}$(NO_COLOR)"
77-
@${EXT_BIN_DIR}/buf generate ${BUF_REPO}:${BUF_LATEST}
78-
79-
.PHONY: buf-generate-dev
80-
buf-generate-dev:
81-
@echo -e "$(ATTN_COLOR)==> $@ ../${PROTO_REPO}/bin/${BUF_DEV_IMAGE}$(NO_COLOR)"
82-
@${EXT_BIN_DIR}/buf generate "../${PROTO_REPO}/bin/${BUF_DEV_IMAGE}"
83-
8471
.PHONY: info
8572
info:
8673
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@@ -97,39 +84,18 @@ info:
9784
@echo "BUF_DEV_IMAGE: ${BUF_DEV_IMAGE}"
9885
@echo "PROTO_REPO: ${PROTO_REPO}"
9986

100-
.PHONY: install-vault
101-
install-vault: ${EXT_BIN_DIR} ${EXT_TMP_DIR}
102-
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
103-
@curl -s -o ${EXT_TMP_DIR}/vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_${GOOS}_${GOARCH}.zip
104-
@unzip -o ${EXT_TMP_DIR}/vault.zip vault -d ${EXT_BIN_DIR}/ &> /dev/null
105-
@chmod +x ${EXT_BIN_DIR}/vault
106-
@${EXT_BIN_DIR}/vault --version
107-
10887
.PHONY: install-buf
10988
install-buf: ${EXT_BIN_DIR}
11089
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
111-
@gh release download v${BUF_VERSION} --repo https://github.com/bufbuild/buf --pattern "buf-$$(uname -s)-$$(uname -m)" --output "${EXT_BIN_DIR}/buf" --clobber
112-
@chmod +x ${EXT_BIN_DIR}/buf
90+
@GOBIN=${EXT_BIN_DIR} go install github.com/bufbuild/buf/cmd/buf@v${BUF_VER}
11391
@${EXT_BIN_DIR}/buf --version
11492

11593
.PHONY: install-svu
116-
install-svu: install-svu-${GOOS}
94+
install-svu: ${EXT_BIN_DIR}
11795
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
118-
@chmod +x ${EXT_BIN_DIR}/svu
96+
@GOBIN=${EXT_BIN_DIR} go install github.com/caarlos0/svu/v3@v${SVU_VER}
11997
@${EXT_BIN_DIR}/svu --version
12098

121-
.PHONY: install-svu-darwin
122-
install-svu-darwin: ${EXT_TMP_DIR} ${EXT_BIN_DIR}
123-
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
124-
@gh release download --repo https://github.com/caarlos0/svu --pattern "svu_*_darwin_all.tar.gz" --output "${EXT_TMP_DIR}/svu.tar.gz" --clobber
125-
@tar -xvf ${EXT_TMP_DIR}/svu.tar.gz --directory ${EXT_BIN_DIR} svu &> /dev/null
126-
127-
.PHONY: install-svu-linux
128-
install-svu-linux: ${EXT_TMP_DIR} ${EXT_BIN_DIR}
129-
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
130-
@gh release download --repo https://github.com/caarlos0/svu --pattern "svu_*_linux_${GOARCH}.tar.gz" --output "${EXT_TMP_DIR}/svu.tar.gz" --clobber
131-
@tar -xvf ${EXT_TMP_DIR}/svu.tar.gz --directory ${EXT_BIN_DIR} svu &> /dev/null
132-
13399
.PHONY: clean
134100
clean:
135101
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
syntax = "proto3";
22

3-
option go_package = "github.com/aserto-dev/go-authorizer/aserto/authorizer/v2/api;api";
4-
option csharp_namespace = "Aserto.Authorizer.V2.API";
5-
63
package aserto.authorizer.v2.api;
74

5+
import "aserto/authorizer/v2/api/identity_context.proto";
6+
import "aserto/authorizer/v2/api/policy_context.proto";
7+
import "aserto/authorizer/v2/api/policy_instance.proto";
88
import "google/protobuf/struct.proto";
99
import "google/protobuf/timestamp.proto";
1010

11-
import "aserto/authorizer/v2/api/policy_context.proto";
12-
import "aserto/authorizer/v2/api/identity_context.proto";
13-
import "aserto/authorizer/v2/api/policy_instance.proto";
11+
option csharp_namespace = "Aserto.Authorizer.V2.API";
12+
option go_package = "github.com/aserto-dev/go-authorizer/aserto/authorizer/v2/api;api";
1413

1514
// represents a decision that an authorizer performed in the past
1615
message Decision {
17-
string id = 1; // unique id, replay a decision starting with this, also useful to de-dup
18-
google.protobuf.Timestamp timestamp = 2; // UTC time when the decision was made
19-
string path = 3; // Policy path used in decision
20-
DecisionUser user = 4; // info about user for whom the decision as made
21-
DecisionPolicy policy = 5; // info about policy used for the decision
22-
map<string, bool> outcomes = 6; // outcome of the decisions specified in the policy context
23-
google.protobuf.Struct resource = 7; // the resource context used in a decision
24-
map<string, string> annotations = 8; // annotations that may be added to a decision
25-
optional string tenant_id = 9; // id of the tenant that generated the decision
16+
string id = 1; // unique id, replay a decision starting with this, also useful to de-dup
17+
google.protobuf.Timestamp timestamp = 2; // UTC time when the decision was made
18+
string path = 3; // Policy path used in decision
19+
DecisionUser user = 4; // info about user for whom the decision as made
20+
DecisionPolicy policy = 5; // info about policy used for the decision
21+
map<string, bool> outcomes = 6; // outcome of the decisions specified in the policy context
22+
google.protobuf.Struct resource = 7; // the resource context used in a decision
23+
map<string, string> annotations = 8; // annotations that may be added to a decision
24+
optional string tenant_id = 9; // id of the tenant that generated the decision
2625
}
2726

2827
// information about a user on behalf of whom a decision was made
29-
message DecisionUser {
30-
aserto.authorizer.v2.api.IdentityContext context = 1; // identity context used in the decision
31-
string id = 2; // id of the user the identity resolved to
32-
string email = 3; // convinience human-readable identifier
28+
message DecisionUser {
29+
aserto.authorizer.v2.api.IdentityContext context = 1; // identity context used in the decision
30+
string id = 2; // id of the user the identity resolved to
31+
string email = 3; // convinience human-readable identifier
3332
}
3433

3534
// information about a policy used in a decision
3635
message DecisionPolicy {
37-
aserto.authorizer.v2.api.PolicyContext context = 1; // policy context used in the decision
38-
string registry_service = 2; // registry service where policy was retrieved from (e.g. opcr.io)
39-
string registry_image = 3; // image of the policy in the registry, including org (e.g. acmecorp/peoplefinder-abac)
40-
string registry_tag = 4; // tag of the policy image (e.g. 0.8.2 or latest)
41-
string registry_digest = 5; // digest of the policy image
42-
aserto.authorizer.v2.api.PolicyInstance policy_instance = 6; // policy instance used in decision
36+
aserto.authorizer.v2.api.PolicyContext context = 1; // policy context used in the decision
37+
string registry_service = 2; // registry service where policy was retrieved from (e.g. opcr.io)
38+
string registry_image = 3; // image of the policy in the registry, including org (e.g. acmecorp/peoplefinder-abac)
39+
string registry_tag = 4; // tag of the policy image (e.g. 0.8.2 or latest)
40+
string registry_digest = 5; // digest of the policy image
41+
aserto.authorizer.v2.api.PolicyInstance policy_instance = 6; // policy instance used in decision
4342
}

0 commit comments

Comments
 (0)