Skip to content

Commit fc2bc57

Browse files
committed
chore: obfuscated endpoint url snippet
1 parent fe74a18 commit fc2bc57

File tree

5 files changed

+119
-0
lines changed

5 files changed

+119
-0
lines changed

pocs/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Developing PoCs.
2+
3+
## Sharing
4+
5+
When developing a GraphQL PoC using IBM API Connect Essentials (StepZen) you will typically
6+
want to share the endpoint to allow others to evaluate it by making GraphQL requests against it.
7+
8+
### Admin key
9+
10+
> [!CAUTION]
11+
> Never share an endpoint by handing out the account's adminkey (`stepzen whoami --adminkey`).
12+
13+
### API key
14+
15+
The most simple (but somewhat risky) approach is to share the account's apikey (`stepzen whoami --apikey`).
16+
17+
The disadvantage with this is the admin key grants access to all endpoints within an account.
18+
Thus if you are working on different PoCs, by providing access to one you provide access to all
19+
which could leak information between different departments or clients.
20+
21+
### Obfuscated endpoints
22+
23+
Obfuscated endpoints allow sharing without handing out any keys or tokens.
24+
25+
The concept can include single-use or short-lived endpoints for a demos, or time-limited evaluations.
26+
27+
> [!WARNING]
28+
> Obfuscated endpoints are public, but have a hard to guess endpoint URL so anyone with the URL has access to the API.
29+
30+
See [obfuscated-endpoint-url](obfuscated-endpoint-url/README.md)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Obfuscated endpoint URL
2+
3+
One simple mechanism to share an IBM API Connect Essentials (StepZen) endpoint to
4+
to make the [endpoint open](../../protection/makeAllPublic/config.yaml) but
5+
deploy the schema with an obfuscated name.
6+
7+
For example, deploy this schema using a randomly generated name (Linux/MacOS):
8+
9+
```
10+
name=$(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z' | fold -w 64 | head -n 1)
11+
stepzen deploy pocs/$name
12+
```
13+
14+
You will see the endpoint is deployed with a random obfuscated URL.
15+
16+
```
17+
Deploying pocs/FzOYquoOMuQzvQqsLSUfVuvQwfVwuOEhGOkGGpLDnuIzeJZCHQAfHbFMCCIQdmBe to StepZen... done in 511ms 🚀
18+
✓ 🔐 https://danville.us-east-a.ibm.stepzen.net/pocs/FzOYquoOMuQzvQqsLSUfVuvQwfVwuOEhGOkGGpLDnuIzeJZCHQAfHbFMCCIQdmBe/__graphql
19+
✓ 🔐 wss://danville.us-east-a.ibm.stepzen.net/stepzen-subscriptions/pocs/FzOYquoOMuQzvQqsLSUfVuvQwfVwuOEhGOkGGpLDnuIzeJZCHQAfHbFMCCIQdmBe/__graphql (subscriptions)
20+
```
21+
22+
This endpoint URL can now be handed out to allow others to evaluate the endpoint without requiring any authorization.
23+
24+
> [!WARNING]
25+
> Anyone with the URL has access to the endpoint, so this is security through obscurity.
26+
27+
Using analytics the account owner can see activity with this specific endpoint,
28+
so be handing out individual endpoints the account owner can track who has evaluated the endpoint.
29+
30+
Thus one can extend thise concept to a "single-use" endpoint, for example creating an endpoint
31+
for a demo and then delete it when no longer required.
32+
33+
```
34+
stepzen delete --non-interactive pocs/FzOYquoOMuQzvQqsLSUfVuvQwfVwuOEhGOkGGpLDnuIzeJZCHQAfHbFMCCIQdmBe
35+
```
36+
37+
By maintaining such endpoints in single folder, such as `pocs` or `single-use` you can use `stepzen list` to
38+
see which endpoints are still active.
39+
40+
```
41+
> stepzen list --folder pocs
42+
Endpoint Created at Updated at
43+
──────────────────────────────────────────────────────────────────────── ──────────────────────── ─────────────────────
44+
pocs/FzOYquoOMuQzvQqsLSUfVuvQwfVwuOEhGOkGGpLDnuIzeJZCHQAfHbFMCCIQdmBe Sep 8, 2024, 12:46 PM Sep 8, 2024, 12:59 PM
45+
```
46+
47+
It is recommended to define a schema description so that this GraphQL introspection request can
48+
used to see the purpose of the obfuscated endpoint.
49+
50+
```
51+
> stepzen request '{__schema{description}}'
52+
{
53+
"data": {
54+
"__schema": {
55+
"description": "Sample mocked Customer endpoint."
56+
}
57+
}
58+
}
59+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
access:
2+
policies:
3+
- type: Query
4+
policyDefault:
5+
condition: true # allow all fields in Query with no authorization
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
Sample mocked Customer endpoint.
3+
"""
4+
schema {
5+
query: Query
6+
}
7+
8+
type Customer @mock {
9+
id: ID!
10+
name: String @mockfn(name: "LastName")
11+
email: String @mockfn(name: "Email")
12+
address: Address
13+
}
14+
15+
type Address {
16+
city: String @mockfn(name: "City")
17+
zip: String @mockfn(name: "Zip")
18+
}
19+
20+
type Query {
21+
customer(id: ID): Customer
22+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"endpoint": "api/misc"
3+
}

0 commit comments

Comments
 (0)