Skip to content

Commit 6b8aec8

Browse files
committed
fix(providers): make the Slack example read-only and align its docs
Slack's read methods accept GET with query-string arguments, and the token travels in the injected authorization header rather than as a query parameter, so the read-only method preset covers reads. Grant read-only access in the example, matching the posture of the GitHub example, and state that write methods such as chat.postMessage need an explicit rule or a read-write copy. Drop the incorrect claim that Slack reads require POST from the profile header and the docs. Offer the raw-URL import form used by the sibling provider pages, using the top-level `openshell profile` commands, and describe where the Slack error name surfaces (the provider_error_subtype field of the refresh status API, echoed in LAST_ERROR). Manual rotation takes the same per-credential refresh locks as the scheduled refresh, so replace the warning that it could race the gateway with the actual cost: each rotation spends the current refresh token. Refs #3729 Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
1 parent e7fc4d9 commit 6b8aec8

3 files changed

Lines changed: 25 additions & 21 deletions

File tree

‎docs/how-it-works/providers/overview.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ openshell provider list-profiles
566566

567567
The repository's
568568
[`providers/`](https://github.com/NVIDIA/OpenShell/tree/main/providers) directory
569-
ships example profiles for GitHub, PyPI, and the major inference and agent
569+
ships example profiles for GitHub, PyPI, Slack, and the major inference and agent
570570
providers. Each file's header states the credential environment variables it
571571
declares, the binaries it authorizes, and the endpoints it grants. Read it,
572572
adjust the binary paths for your image, and import your copy.

‎docs/how-it-works/providers/slack.mdx‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ configuration below.
4343
Slack refresh tokens are single use. Every refresh returns a new refresh
4444
token and invalidates the previous one, so only the gateway should refresh a
4545
rotating grant. Do not reuse the refresh token you hand to the gateway
46-
elsewhere, and avoid manual `refresh rotate` calls that could race the
47-
gateway's own scheduled refresh.
46+
elsewhere. A manual `openshell provider refresh rotate` is serialized with the
47+
gateway's scheduled refresh for the same credential, so it does not race it,
48+
but each rotation spends the current refresh token.
4849
</Warning>
4950

5051
## Import the Example Profile
@@ -53,13 +54,14 @@ The repository ships `providers/slack.yaml` as a reviewable example. Lint and
5354
import it (drop `--global` to import into the current workspace only):
5455

5556
```shell
56-
openshell provider profile lint -f providers/slack.yaml
57-
openshell provider profile import -f providers/slack.yaml --global
57+
openshell profile lint --url https://raw.githubusercontent.com/NVIDIA/OpenShell/main/providers/slack.yaml
58+
openshell profile import --url https://raw.githubusercontent.com/NVIDIA/OpenShell/main/providers/slack.yaml --global
5859
```
5960

60-
Copy and adapt it if your workload needs narrower `endpoints` rules or a
61-
different `binaries` list; the example allows the Slack Web API host for
62-
any binary in the sandbox.
61+
From a checkout, `-f providers/slack.yaml` works the same way. The example
62+
grants read-only access to `slack.com` for `curl`; copy and adapt it if your
63+
workload uses a different client binary or needs write methods such as
64+
`chat.postMessage`, which require explicit `rules` or `access: read-write`.
6365

6466
## Create the Provider
6567

@@ -101,19 +103,19 @@ field. The gateway classifies those like standard OAuth errors:
101103
| `invalid_client_id`, `bad_client_secret` | `oauth_invalid_client` | `fix_configuration`: correct the client material. |
102104
| `ratelimited` and other transient Slack errors | `oauth_token_endpoint_retryable` | `retry`: the gateway retries automatically. |
103105

104-
The Slack error name is kept in the provider error subtype of the refresh
105-
status so operators can see the original cause.
106+
The Slack error name is recorded as `provider_error_subtype` in the refresh
107+
status API and echoed in the `LAST_ERROR` text of the status table.
106108

107109
## Use the Provider in a Sandbox
108110

109111
```shell
110112
openshell sandbox create --name slack-sandbox --provider my-slack
111113
openshell sandbox exec slack-sandbox -- \
112-
curl -s -X POST https://slack.com/api/auth.test \
114+
curl -s https://slack.com/api/auth.test \
113115
-H "Authorization: Bearer $SLACK_USER_TOKEN"
114116
```
115117

116118
The sandbox sees only the placeholder; the sandbox proxy substitutes the
117-
current access token for requests to `slack.com`. Restrict the allowed
118-
methods with a custom profile that adds `rules` for the Slack Web API paths
119-
your workload needs.
119+
current access token for requests to `slack.com`. The example allows read
120+
methods only; add `rules` for the specific Slack Web API paths your workload
121+
needs, including any write methods.

‎providers/slack.yaml‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
# it stays at the gateway and is never injected. Slack access
2020
# tokens live 43200 s and refresh tokens are single use, so
2121
# only the gateway should refresh them.
22-
# Endpoint access: slack.com:443 with the read-write method preset (Slack Web
23-
# API methods are POST even for reads). Add `rules` for the
24-
# methods your workload needs.
22+
# Endpoint access: slack.com:443 read-only (GET/HEAD/OPTIONS). Slack's read
23+
# methods accept GET with query-string arguments; the token
24+
# travels in the injected authorization header, never as a
25+
# query parameter. Writes such as chat.postMessage need an
26+
# explicit `rules` entry or a copy with `access: read-write`.
2527
# Smoke test: openshell sandbox create --provider <name> -- \
26-
# curl -s -X POST https://slack.com/api/auth.test \
28+
# curl -s https://slack.com/api/auth.test \
2729
# -H "Authorization: Bearer $SLACK_USER_TOKEN"
2830

2931
id: slack
@@ -67,12 +69,12 @@ discovery:
6769
credentials: [user_token]
6870

6971
endpoints:
70-
# Slack Web API methods are POST even for reads, so the read-only
71-
# method preset is unusable; read-write is the minimum working preset.
72+
# Slack's read methods accept GET, so the read-only preset covers reads
73+
# while keeping write methods denied until a policy explicitly allows them.
7274
- host: slack.com
7375
port: 443
7476
protocol: rest
75-
access: read-write
77+
access: read-only
7678
enforcement: enforce
7779

7880
binaries:

0 commit comments

Comments
 (0)