Skip to content

Commit 1145e91

Browse files
authored
Merge pull request #74 from cipherstash/fix-xorm
fix: use playground setup in all example
2 parents d2f873c + 838594e commit 1145e91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+529
-1118
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Store encrypted data alongside your existing data:
1313
- Encrypted data is stored using a `jsonb` column type
1414
- Query encrypted data with specialized SQL functions
1515
- Index encrypted columns to enable searchable encryption
16-
- Integrate with [CipherStash Proxy](/docs/tutorials/PROXY.md) for transparent encryption/decryption
16+
- Integrate with [CipherStash Proxy](/docs/tutorials/PROXY.md) for transparent encryption/decryption.
1717

1818
## Table of Contents
1919

@@ -65,6 +65,8 @@ The simplest way to get up and running with EQL is to execute the install SQL fi
6565
EQL relies on [CipherStash Proxy](docs/tutorials/PROXY.md) for low-latency encryption & decryption.
6666
We plan to support direct language integration in the future.
6767

68+
If you want to use CipherStash Proxy with the below examples or the [helper packages](#helper-packages-and-examples), you can use the [playground environment](playground/README.md).
69+
6870
## Documentation
6971

7072
You can read more about the EQL concepts and reference guides in the [documentation directory](docs/README.md).
File renamed without changes.

examples/go/xorm/.envrc.example

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

examples/go/xorm/README.md

Lines changed: 24 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,63 +10,15 @@
1010

1111
## Running / Development
1212

13-
Create an [account](https://cipherstash.com/signup).
14-
15-
Install the CLI:
16-
17-
```shell
18-
brew install cipherstash/tap/stash
19-
```
20-
21-
Login:
22-
23-
```shell
24-
stash login
25-
```
26-
27-
Create a [dataset](https://cipherstash.com/docs/how-to/creating-datasets) and [client](https://cipherstash.com/docs/how-to/creating-clients), and record them as `CS_CLIENT_ID` and `CS_CLIENT_KEY`.
28-
29-
```shell
30-
stash datasets create xorm
31-
# grab dataset ID and export CS_DATASET_ID=
32-
33-
stash clients create xorm --dataset-id $CS_DATASET_ID
34-
# grab the client ID and export CS_CLIENT_ID=
35-
# grab the client key and export CS_CLIENT_KEY=
36-
```
37-
38-
Create an [access key](https://cipherstash.com/docs/how-to/creating-access-keys) for CipherStash Proxy:
39-
40-
```shell
41-
stash workspaces
42-
# grab the workspace ID and export CS_WORKSPACE_ID=
43-
stash access-keys create --workspace-id $CS_WORKSPACE_ID xorm
44-
# grab the client access key and export CS_CLIENT_ACCESS_KEY=
45-
```
46-
47-
Copy over the example `.envrc` file:
48-
49-
```shell
50-
cp .envrc.example .envrc
51-
```
52-
53-
Update the `.envrc` file with these environment variables `CS_WORKSPACE_ID`, `CS_CLIENT_ACCESS_KEY`, `CS_CLIENT_ID`, `CS_CLIENT_KEY` and `CS_DATASET_ID`:
54-
55-
```shell
56-
source .envrc
57-
```
58-
59-
Start Postgres and CipherStash Proxy and install EQL:
60-
61-
```shell
62-
./run.sh setup
63-
```
64-
65-
Run tests:
66-
67-
```shell
68-
./run.sh tests
69-
```
13+
1. Set up the [playground environment](../../playground/README.md).
14+
2. Run the setup script:
15+
```shell
16+
./run.sh setup
17+
```
18+
3. Run tests:
19+
```shell
20+
./run.sh tests
21+
```
7022

7123
## Integrating EQL into a Xorm app
7224

@@ -115,8 +67,8 @@ Example for a text field:
11567
```go
11668
func (et EncryptedTextField) ToDB() ([]byte, error) {
11769
etCs := goeql.EncryptedText(et)
118-
// e.g table name is "examples" and field is "encrypted_text_field"
119-
return (&etCs).Serialize("examples", "encrypted_text_field")
70+
// e.g table name is "goexamples" and field is "encrypted_text_field"
71+
return (&etCs).Serialize("goexamples", "encrypted_text_field")
12072
}
12173
12274
func (et *EncryptedTextField) FromDB(data []byte) error {
@@ -138,8 +90,8 @@ Example for a jsonb field:
13890
```go
13991
func (ej EncryptedJsonbField) ToDB() ([]byte, error) {
14092
ejCs := goeql.EncryptedJsonb(ej)
141-
// e.g table name is "examples" and field is "encrypted_jsonb_field"
142-
return (&ejCs).Serialize("examples", "encrypted_jsonb_field")
93+
// e.g table name is "goexamples" and field is "encrypted_jsonb_field"
94+
return (&ejCs).Serialize("goexamples", "encrypted_jsonb_field")
14395
}
14496
14597
func (ej *EncryptedJsonbField) FromDB(data []byte) error {
@@ -163,10 +115,10 @@ These checks will validate that the json payload is correct and that encrypted d
163115
Example:
164116
165117
```sql
166-
ALTER TABLE examples ADD CONSTRAINT encrypted_text_field_encrypted_check
118+
ALTER TABLE goexamples ADD CONSTRAINT encrypted_text_field_encrypted_check
167119
CHECK ( cs_check_encrypted_v1(encrypted_text_field) );
168120
169-
ALTER TABLE examples ADD CONSTRAINT encrypted_jsonb_encrypted_check
121+
ALTER TABLE goexamples ADD CONSTRAINT encrypted_jsonb_encrypted_check
170122
CHECK ( cs_check_encrypted_v1(encrypted_jsonb_field) );
171123
```
172124
@@ -175,17 +127,17 @@ Example:
175127
Example:
176128
177129
```sql
178-
SELECT cs_add_index_v1('examples', 'encrypted_text_field', 'unique', 'text', '{"token_filters": [{"kind": "downcase"}]}');
179-
SELECT cs_add_index_v1('examples', 'encrypted_text_field', 'match', 'text');
180-
SELECT cs_add_index_v1('examples', 'encrypted_text_field', 'ore', 'text');
181-
SELECT cs_add_index_v1('examples', 'encrypted_jsonb_field', 'ste_vec', 'jsonb', '{"prefix": "examples/encrypted_jsonb_field"}');
130+
SELECT cs_add_index_v1('goexamples', 'encrypted_text_field', 'unique', 'text', '{"token_filters": [{"kind": "downcase"}]}');
131+
SELECT cs_add_index_v1('goexamples', 'encrypted_text_field', 'match', 'text');
132+
SELECT cs_add_index_v1('goexamples', 'encrypted_text_field', 'ore', 'text');
133+
SELECT cs_add_index_v1('goexamples', 'encrypted_jsonb_field', 'ste_vec', 'jsonb', '{"prefix": "goexamples/encrypted_jsonb_field"}');
182134
183135
-- The below indexes will also need to be added to enable full search functionality on the encrypted columns
184136
185-
CREATE UNIQUE INDEX ON examples(cs_unique_v1(encrypted_text_field));
186-
CREATE INDEX ON examples USING GIN (cs_match_v1(encrypted_text_field));
187-
CREATE INDEX ON examples (cs_ore_64_8_v1(encrypted_text_field));
188-
CREATE INDEX ON examples USING GIN (cs_ste_vec_v1(encrypted_jsonb_field));
137+
CREATE UNIQUE INDEX ON goexamples(cs_unique_v1(encrypted_text_field));
138+
CREATE INDEX ON goexamples USING GIN (cs_match_v1(encrypted_text_field));
139+
CREATE INDEX ON goexamples (cs_ore_64_8_v1(encrypted_text_field));
140+
CREATE INDEX ON goexamples USING GIN (cs_ste_vec_v1(encrypted_jsonb_field));
189141
190142
-- Run these functions to activate
191143
@@ -222,7 +174,7 @@ Examples of how to use these are in the [e2e_test.go](./e2e_test.go) file.
222174
Below is an example of running a match query on a text field.
223175
224176
```go
225-
query, errTwo := goeql.MatchQuery("some", "examples", "encrypted_text_field")
177+
query, errTwo := goeql.MatchQuery("some", "goexamples", "encrypted_text_field")
226178
if errTwo != nil {
227179
log.Fatalf("Error marshaling encrypted_text_field: %v", errTwo)
228180
}

examples/go/xorm/docker-compose.yml

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

0 commit comments

Comments
 (0)