Skip to content

Commit 0c51d74

Browse files
authored
update tls-simple, tls-full, and extensibility authorizer to use ES visibility and temporal cli (#109)
1 parent 38f29ed commit 0c51d74

5 files changed

Lines changed: 51 additions & 59 deletions

File tree

extensibility/authorizer/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ The sample implementation of the authorizer interface `authorization.Authorizer`
66
### Steps to run this sample
77
1. Start up the dependencies by running the `make start-dependencies` command from within the main Temporal repository as described in the [contribution guide](https://github.com/temporalio/temporal/blob/master/CONTRIBUTING.md#run-temporal-server-locally).
88

9-
2. Create the database schema by running `make install-schema`.
9+
2. Create the database schema by running `make install-schema-cass-es`.
1010

1111
3. Start Temporal by running `go run authorizer/server/main.go`.
1212

13-
4. Use `tctl` to interact with Temporal
13+
4. Use `temporal` cli to interact with Temporal
1414

15-
- Run `tctl n l` to list available namespaces. You should only see "temporal-system" initially.
16-
- Run `tctl --ns test n register` to create a namespace "test"
17-
- Run `tctl n l` to see "test" listed
18-
- Run `tctl --ns test n update` to try to update the "test" namespace. You should see a `PermissionDenied` error because `myAuthorizer` denies `UpdateNamespace` calls.
15+
- Run `temporal operator namespace list` to list available namespaces. You should only see "temporal-system" initially.
16+
- Run `temporal operator namespace create -n test` to create a namespace "test"
17+
- Run `temporal operator namespace list` to see "test" listed
18+
- Run `temporal operator namespace update -n test` to try to update the "test" namespace. You should see a `PermissionDenied` error because `myAuthorizer` denies `UpdateNamespace` calls.

extensibility/authorizer/myAuthorizer.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package authorizer
2424

2525
import (
2626
"context"
27+
"strings"
2728

2829
"go.temporal.io/server/common/authorization"
2930
)
@@ -48,20 +49,20 @@ func (a *myAuthorizer) Authorize(_ context.Context, claims *authorization.Claims
4849
return decisionAllow, nil
4950
}
5051

51-
// Allow all calls except UpdateNamespace through when claim mapper isn't invoked
52-
// Claim mapper is skipped unless TLS is configured or an auth token is passed
53-
if claims == nil && target.APIName != "UpdateNamespace" {
52+
// Allow all operations for system-level admins and writers
53+
if claims != nil && claims.System&(authorization.RoleAdmin|authorization.RoleWriter) != 0 {
5454
return decisionAllow, nil
5555
}
5656

57-
// Allow all operations for system-level admins and writers
58-
if claims.System & (authorization.RoleAdmin | authorization.RoleWriter) != 0 {
57+
// Allow all calls except UpdateNamespace through when claim mapper isn't invoked
58+
// Claim mapper is skipped unless TLS is configured or an auth token is passed
59+
if claims == nil && !strings.Contains(target.APIName, "UpdateNamespace") {
5960
return decisionAllow, nil
6061
}
6162

6263
// For other namespaces, deny "UpdateNamespace" API unless the caller has a writer role in it
63-
if target.APIName == "UpdateNamespace" {
64-
if claims.Namespaces[target.Namespace] & authorization.RoleWriter != 0 {
64+
if strings.Contains(target.APIName, "UpdateNamespace") {
65+
if claims != nil && claims.Namespaces[target.Namespace]&authorization.RoleWriter != 0 {
6566
return decisionAllow, nil
6667
} else {
6768
return decisionDeny, nil

extensibility/config/development.yaml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
persistence:
22
defaultStore: cass-default
3-
visibilityStore: cass-visibility
3+
visibilityStore: es-visibility
44
numHistoryShards: 4
55
datastores:
66
cass-default:
77
cassandra:
88
hosts: "127.0.0.1"
99
keyspace: "temporal"
10-
cass-visibility:
11-
cassandra:
12-
hosts: "127.0.0.1"
13-
keyspace: "temporal_visibility"
10+
es-visibility:
11+
elasticsearch:
12+
version: "v7"
13+
logLevel: "error"
14+
url:
15+
scheme: "http"
16+
host: "127.0.0.1:9200"
17+
indices:
18+
visibility: temporal_visibility_v1_dev
19+
# secondary_visibility: temporal_visibility_v1_secondary
20+
closeIdleConnectionsInterval: 15s
1421
global:
1522
membership:
1623
maxJoinDuration: 30s
@@ -102,19 +109,6 @@ namespaceDefaults:
102109
state: "disabled"
103110
URI: "file:///tmp/temporal_vis_archival/development"
104111

105-
kafka:
106-
tls:
107-
enabled: false
108-
clusters:
109-
test:
110-
brokers:
111-
- 127.0.0.1:9092
112-
topics:
113-
temporal-visibility-dev:
114-
cluster: test
115-
temporal-visibility-dev-dlq:
116-
cluster: test
117-
118112
publicClient:
119113
hostPort: "localhost:7233"
120114

tls/tls-simple/README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,10 @@ After disabling client authentication as per the above directions, you could use
2828
```bash
2929
temporal operator namespace create \
3030
--tls-ca-path certs/ca.cert \
31+
--tls-cert-path certs/client.pem \
32+
--tls-key-path certs/client.key \
3133
--tls-server-name tls-sample \
32-
testing
33-
```
34-
35-
Here is the corresponding `tctl` command:
36-
```bash
37-
tctl \
38-
--tls_ca_path certs/ca.cert \
39-
--tls_server_name tls-sample \
40-
--namespace testing \
41-
namespace register
34+
-n testing
4235
```
4336

4437
#### Connecting to the Cluster via TLS (Go SDK)

tls/tls-simple/docker-compose.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ services:
55
image: cassandra:3.11
66
ports:
77
- "9042:9042"
8+
elasticsearch:
9+
image: elasticsearch:7.10.1
10+
ports:
11+
- "9200:9200"
12+
environment:
13+
- "cluster.routing.allocation.disk.threshold_enabled=true"
14+
- "cluster.routing.allocation.disk.watermark.low=512mb"
15+
- "cluster.routing.allocation.disk.watermark.high=256mb"
16+
- "cluster.routing.allocation.disk.watermark.flood_stage=128mb"
17+
- "discovery.type=single-node"
18+
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
19+
- "xpack.security.enabled=false"
820
temporal:
921
image: temporalio/auto-setup:${SERVER_TAG:-latest}
1022
ports:
@@ -13,35 +25,33 @@ services:
1325
- ${DYNAMIC_CONFIG_DIR:-../config/dynamicconfig}:/etc/temporal/config/dynamicconfig
1426
- ${TEMPORAL_LOCAL_CERT_DIR}:${TEMPORAL_TLS_CERTS_DIR}
1527
environment:
16-
- "CASSANDRA_SEEDS=cassandra"
1728
- "DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development.yaml"
29+
- "CASSANDRA_SEEDS=cassandra"
30+
- "ENABLE_ES=true"
31+
- "ES_SEEDS=elasticsearch"
1832
- "SKIP_DEFAULT_NAMESPACE_CREATION=true"
33+
- "SKIP_ADD_CUSTOM_SEARCH_ATTRIBUTES=true"
1934
- "TEMPORAL_TLS_SERVER_CA_CERT=${TEMPORAL_TLS_CERTS_DIR}/ca.cert"
2035
- "TEMPORAL_TLS_SERVER_CERT=${TEMPORAL_TLS_CERTS_DIR}/cluster.pem"
2136
- "TEMPORAL_TLS_SERVER_KEY=${TEMPORAL_TLS_CERTS_DIR}/cluster.key"
2237
- "TEMPORAL_TLS_REQUIRE_CLIENT_AUTH=true"
23-
- "TEMPORAL_TLS_FRONTEND_CERT=${TEMPORAL_TLS_CERTS_DIR}/cluster.pem"
24-
- "TEMPORAL_TLS_FRONTEND_KEY=${TEMPORAL_TLS_CERTS_DIR}/cluster.key"
2538
- "TEMPORAL_TLS_CLIENT1_CA_CERT=${TEMPORAL_TLS_CERTS_DIR}/ca.cert"
2639
- "TEMPORAL_TLS_CLIENT2_CA_CERT=${TEMPORAL_TLS_CERTS_DIR}/ca.cert"
27-
- "TEMPORAL_TLS_INTERNODE_SERVER_NAME=tls-sample"
40+
- "TEMPORAL_TLS_FRONTEND_CERT=${TEMPORAL_TLS_CERTS_DIR}/cluster.pem"
41+
- "TEMPORAL_TLS_FRONTEND_KEY=${TEMPORAL_TLS_CERTS_DIR}/cluster.key"
2842
- "TEMPORAL_TLS_FRONTEND_SERVER_NAME=tls-sample"
2943
- "TEMPORAL_TLS_FRONTEND_DISABLE_HOST_VERIFICATION=false"
44+
- "TEMPORAL_TLS_INTERNODE_SERVER_NAME=tls-sample"
3045
- "TEMPORAL_TLS_INTERNODE_DISABLE_HOST_VERIFICATION=false"
31-
- "TEMPORAL_CLI_ADDRESS=temporal:7233" # used by tctl. Will be deprecated
32-
- "TEMPORAL_CLI_TLS_CA=${TEMPORAL_TLS_CERTS_DIR}/ca.cert"
33-
- "TEMPORAL_CLI_TLS_CERT=${TEMPORAL_TLS_CERTS_DIR}/cluster.pem"
34-
- "TEMPORAL_CLI_TLS_KEY=${TEMPORAL_TLS_CERTS_DIR}/cluster.key"
35-
- "TEMPORAL_CLI_TLS_ENABLE_HOST_VERIFICATION=true"
36-
- "TEMPORAL_CLI_TLS_SERVER_NAME=tls-sample"
37-
- "TEMPORAL_ADDRESS=temporal:7233" # used by Temporal CLI
46+
- "TEMPORAL_ADDRESS=temporal:7233"
3847
- "TEMPORAL_TLS_CA=${TEMPORAL_TLS_CERTS_DIR}/ca.cert"
3948
- "TEMPORAL_TLS_CERT=${TEMPORAL_TLS_CERTS_DIR}/cluster.pem"
4049
- "TEMPORAL_TLS_KEY=${TEMPORAL_TLS_CERTS_DIR}/cluster.key"
4150
- "TEMPORAL_TLS_ENABLE_HOST_VERIFICATION=true"
4251
- "TEMPORAL_TLS_SERVER_NAME=tls-sample"
4352
depends_on:
4453
- cassandra
54+
- elasticsearch
4555
temporal-ui:
4656
image: temporalio/ui:${UI_TAG:-latest}
4757
ports:
@@ -64,13 +74,7 @@ services:
6474
volumes:
6575
- ${TEMPORAL_LOCAL_CERT_DIR}:${TEMPORAL_TLS_CERTS_DIR}
6676
environment:
67-
- "TEMPORAL_CLI_ADDRESS=temporal:7233" # used by tctl. Will be deprecated
68-
- "TEMPORAL_CLI_TLS_CA=${TEMPORAL_TLS_CERTS_DIR}/ca.cert"
69-
- "TEMPORAL_CLI_TLS_CERT=${TEMPORAL_TLS_CERTS_DIR}/client.pem"
70-
- "TEMPORAL_CLI_TLS_KEY=${TEMPORAL_TLS_CERTS_DIR}/client.key"
71-
- "TEMPORAL_CLI_TLS_ENABLE_HOST_VERIFICATION=true"
72-
- "TEMPORAL_CLI_TLS_SERVER_NAME=tls-sample"
73-
- "TEMPORAL_ADDRESS=temporal:7233" # used by Temporal CLI
77+
- "TEMPORAL_ADDRESS=temporal:7233"
7478
- "TEMPORAL_TLS_CA=${TEMPORAL_TLS_CERTS_DIR}/ca.cert"
7579
- "TEMPORAL_TLS_CERT=${TEMPORAL_TLS_CERTS_DIR}/client.pem"
7680
- "TEMPORAL_TLS_KEY=${TEMPORAL_TLS_CERTS_DIR}/client.key"

0 commit comments

Comments
 (0)