Skip to content
This repository was archived by the owner on Jun 18, 2025. It is now read-only.

Commit f669bbf

Browse files
authored
Support providing an x.509 certificate for user authentication (#184)
1 parent 2f0cfc7 commit f669bbf

19 files changed

Lines changed: 447 additions & 47 deletions

.github/workflows/pull-request.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ jobs:
4040
esdb_version: ${{ matrix.version }}
4141
go_version: ${{ needs.go-version.outputs.go_version }}
4242

43+
plugins-tests:
44+
needs: build
45+
name: Plugins Tests
46+
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
version: [24.2.0-jammy]
51+
52+
uses: ./.github/workflows/test-plugins.yml
53+
with:
54+
esdb_version: ${{ matrix.version }}
55+
go_version: ${{ needs.go-version.outputs.go_version }}
56+
esdb_repository: "docker.eventstore.com/eventstore-ee/eventstoredb-commercial"
57+
secrets: inherit
4358

4459
linting:
4560
needs: tests

.github/workflows/test-dispatch.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,13 @@ jobs:
1919
with:
2020
esdb_version: ${{ inputs.version }}
2121
go_version: ${{ needs.go-version.outputs.go_version }}
22+
23+
plugins-tests:
24+
needs: go-version
25+
name: Plugins Tests
26+
uses: ./.github/workflows/plugins-tests.yml
27+
with:
28+
esdb_version: ${{ inputs.version }}
29+
go_version: ${{ needs.go-version.outputs.go_version }}
30+
esdb_repository: "docker.eventstore.com/eventstore-ee/eventstoredb-commercial"
31+
secrets: inherit

.github/workflows/test-plugins.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: enterprise plugins tests workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
esdb_repository:
7+
required: true
8+
type: string
9+
10+
esdb_version:
11+
required: true
12+
type: string
13+
14+
go_version:
15+
required: true
16+
type: string
17+
18+
jobs:
19+
secure:
20+
name: Secure
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
test: [Plugins]
26+
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: actions/setup-go@v5
31+
with:
32+
go-version: ${{ inputs.go_version }}
33+
34+
- name: Login to Cloudsmith
35+
uses: docker/login-action@v3
36+
with:
37+
registry: docker.eventstore.com
38+
username: ${{ secrets.CLOUDSMITH_CICD_USER }}
39+
password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }}
40+
41+
- name: Generate certificates
42+
run: docker compose --file docker-compose.yml up
43+
44+
- name: Run Go Tests
45+
run: make ci CI_TARGET=Test${{ matrix.test }}
46+
47+
env:
48+
EVENTSTORE_DOCKER_REPOSITORY: ${{ inputs.esdb_repository }}
49+
EVENTSTORE_DOCKER_TAG: ${{ inputs.esdb_version }}
50+
EVENTSTORE_INSECURE: false
51+
52+
cluster:
53+
name: Cluster
54+
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
test: [Plugins]
59+
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v4
63+
- uses: actions/setup-go@v5
64+
with:
65+
go-version: ${{ inputs.go_version }}
66+
67+
- name: Login to Cloudsmith
68+
uses: docker/login-action@v3
69+
with:
70+
registry: docker.eventstore.com
71+
username: ${{ secrets.CLOUDSMITH_CICD_USER }}
72+
password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }}
73+
74+
- name: Set up cluster with Docker Compose
75+
run: |
76+
docker compose -f cluster-docker-compose.yml up -d
77+
env:
78+
EVENTSTORE_DOCKER_REPOSITORY: ${{ inputs.esdb_repository }}
79+
EVENTSTORE_DOCKER_TAG: ${{ inputs.esdb_version }}
80+
81+
- name: Run Go Tests
82+
run: make ci CI_TARGET=Test${{ matrix.test }}
83+
env:
84+
EVENTSTORE_INSECURE: false
85+
CLUSTER: true
86+
87+
- name: Shutdown cluster
88+
run: docker compose -f cluster-docker-compose.yml down
89+
if: always()

.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ jobs:
2828
go-version: ${{ inputs.go_version }}
2929

3030
- name: Generate certificates
31-
run: docker-compose --file docker-compose.yml up
31+
run: docker compose --file docker-compose.yml up
3232

3333
- name: Run Go Tests
3434
run: make ci CI_TARGET=Test${{ matrix.test }}
3535
env:
36-
EVENTSTORE_DOCKER_TAG_ENV: ${{ inputs.esdb_version }}
36+
EVENTSTORE_DOCKER_TAG: ${{ inputs.esdb_version }}
3737
EVENTSTORE_INSECURE: true
3838

3939
secure:
@@ -52,13 +52,13 @@ jobs:
5252
go-version: ${{ inputs.go_version }}
5353

5454
- name: Generate certificates
55-
run: docker-compose --file docker-compose.yml up
55+
run: docker compose --file docker-compose.yml up
5656

5757
- name: Run Go Tests
5858
run: make ci CI_TARGET=Test${{ matrix.test }}
5959

6060
env:
61-
EVENTSTORE_DOCKER_TAG_ENV: ${{ inputs.esdb_version }}
61+
EVENTSTORE_DOCKER_TAG: ${{ inputs.esdb_version }}
6262
EVENTSTORE_INSECURE: false
6363

6464
cluster:
@@ -80,7 +80,7 @@ jobs:
8080
run: |
8181
docker compose -f cluster-docker-compose.yml up -d
8282
env:
83-
EVENTSTORE_DOCKER_TAG_ENV: ${{ inputs.esdb_version }}
83+
EVENTSTORE_DOCKER_TAG: ${{ inputs.esdb_version }}
8484

8585
- name: Run Go Tests
8686
run: make ci CI_TARGET=Test${{ matrix.test }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ _testmain.go
2727
.idea
2828

2929
certs/
30-
tools/
30+
tools/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ else
2828
$(MAKE) build GENERATE_PROTOS_FLAG=-generateProtos
2929
endif
3030

31-
DOCKER_COMPOSE_CMD := $(shell command -v docker-compose 2> /dev/null)
31+
DOCKER_COMPOSE_CMD := $(shell command -v docker compose 2> /dev/null)
3232
ifeq ($(DOCKER_COMPOSE_CMD),)
3333
DOCKER_COMPOSE_CMD := docker compose
3434
endif

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ make generate-protos-and-build
3232
make test
3333
```
3434

35-
By default the tests use `docker.eventstore.com/eventstore-ce:ci`. To override this, set the `EVENTSTORE_DOCKER_TAG_ENV` environment variable to the tag you wish to use:
35+
By default the tests use `docker.eventstore.com/eventstore-ce:ci`. To override this, set the `EVENTSTORE_DOCKER_TAG` environment variable to the tag you wish to use:
3636

3737
```shell
38-
export EVENTSTORE_DOCKER_TAG_ENV="21.10.0-focal"
38+
export EVENTSTORE_DOCKER_TAG="21.10.0-focal"
3939
make test
4040
```
4141

cluster-docker-compose.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ services:
1919
&& es-gencert-cli create-node -out ./node1 -ip-addresses 127.0.0.1,172.30.240.11 -dns-names localhost
2020
&& es-gencert-cli create-node -out ./node2 -ip-addresses 127.0.0.1,172.30.240.12 -dns-names localhost
2121
&& es-gencert-cli create-node -out ./node3 -ip-addresses 127.0.0.1,172.30.240.13 -dns-names localhost
22+
&& es-gencert-cli create-user -username admin
23+
&& es-gencert-cli create-user -username invalid
2224
&& find . -type f -print0 | xargs -0 chmod 666"
2325
volumes:
2426
- "./certs:/certs"
2527
depends_on:
2628
- volumes-provisioner
2729

2830
esdb-node1:
29-
image: docker.eventstore.com/eventstore-ce/eventstoredb-ce:${EVENTSTORE_DOCKER_TAG_ENV:-latest}
31+
image: ${EVENTSTORE_DOCKER_REPOSITORY:-docker.eventstore.com/eventstore-ce/eventstoredb-ce}:${EVENTSTORE_DOCKER_TAG:-latest}
3032
env_file:
3133
- shared.env
3234
environment:
@@ -47,7 +49,7 @@ services:
4749
- cert-gen
4850

4951
esdb-node2:
50-
image: docker.eventstore.com/eventstore-ce/eventstoredb-ce:${EVENTSTORE_DOCKER_TAG_ENV:-latest}
52+
image: ${EVENTSTORE_DOCKER_REPOSITORY:-docker.eventstore.com/eventstore-ce/eventstoredb-ce}:${EVENTSTORE_DOCKER_TAG:-latest}
5153
env_file:
5254
- shared.env
5355
environment:
@@ -68,7 +70,7 @@ services:
6870
- cert-gen
6971

7072
esdb-node3:
71-
image: docker.eventstore.com/eventstore-ce/eventstoredb-ce:${EVENTSTORE_DOCKER_TAG_ENV:-latest}
73+
image: ${EVENTSTORE_DOCKER_REPOSITORY:-docker.eventstore.com/eventstore-ce/eventstoredb-ce}:${EVENTSTORE_DOCKER_TAG:-latest}
7274
env_file:
7375
- shared.env
7476
environment:

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ services:
1818
&& es-gencert-cli create-ca
1919
&& es-gencert-cli create-node -out ./node --dns-names localhost
2020
&& es-gencert-cli create-ca -out ./untrusted-ca
21+
&& es-gencert-cli create-user -username admin
22+
&& es-gencert-cli create-user -username invalid
2123
&& find . -type f -print0 | xargs -0 chmod 666"
2224
container_name: setup
2325
volumes:

esdb/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ type Client struct {
2525

2626
// NewClient Creates a gRPC client to an EventStoreDB database.
2727
func NewClient(configuration *Configuration) (*Client, error) {
28+
if err := configuration.Validate(); err != nil {
29+
return nil, fmt.Errorf("invalid configuration: %w", err)
30+
}
31+
2832
grpcClient := newGrpcClient(*configuration)
2933
return &Client{
3034
grpcClient: grpcClient,

0 commit comments

Comments
 (0)