Commit d36b84e
committed
feat(sparql-proxy): reader credential + configurable read auth
Split the Caddyfile's single basic_auth block into two role-based
blocks so deployments can issue a read-only credential separately
from the admin/write credential.
- Writes (POST/PUT/DELETE/PATCH on /update and /store) always require
Basic Auth, accepting only credentials from `users/admin/*`. This
was the previous behavior, now isolated to its own block.
- Reads can optionally be gated. The new `@reads_protected` matcher
reads its path list from the `SPARQL_READ_AUTH_PATHS` env var on
the sparql-proxy container. The default (`__off__`) is a sentinel
that matches no real request, so reads stay public until an
operator opts in by setting e.g.
`SPARQL_READ_AUTH_PATHS=/query /query/*` in `.env`. When the matcher
fires, it accepts credentials from EITHER `users/admin/*` or the
new `users/reader/*` — admin keeps full access, reader can issue
read-only access to clients.
Env / config plumbing:
- compose: sparql-proxy gets an `environment:` block that forwards
`SPARQL_READ_AUTH_PATHS` (default `__off__`) into the container.
- `infra/.env.example`: documents the optional new vars
`SPARQL_READER_AUTH=reader/<password>` and
`SPARQL_READ_AUTH_PATHS=/query /query/*`.
- `scripts/fix-data-perms.sh`: now writes `users/admin/sparql_users.caddy`
from `SPARQL_AUTH` and (if set) `users/reader/sparql_reader.caddy`
from `SPARQL_READER_AUTH`. Migrates the legacy single-file layout
(`users/sparql_users.caddy`) into `users/admin/` automatically.
Backward-compat:
- Deployments that don't set `SPARQL_READER_AUTH` or
`SPARQL_READ_AUTH_PATHS` behave identically to before — anonymous
reads, admin-only writes.
- The legacy users-file path migrates in place when `fix-data-perms.sh`
runs (which the deploy procedure now invokes as standard).1 parent 4e82739 commit d36b84e
4 files changed
Lines changed: 122 additions & 44 deletions
File tree
- infra
- open-pulse-stack
- services/sparql-proxy
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
284 | 291 | | |
285 | 292 | | |
286 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
5 | 6 | | |
6 | | - | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
31 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
32 | 57 | | |
33 | 58 | | |
34 | 59 | | |
35 | 60 | | |
36 | | - | |
37 | | - | |
38 | 61 | | |
39 | | - | |
| 62 | + | |
40 | 63 | | |
41 | 64 | | |
42 | | - | |
43 | | - | |
| 65 | + | |
| 66 | + | |
44 | 67 | | |
45 | 68 | | |
46 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
130 | 162 | | |
131 | | - | |
| 163 | + | |
132 | 164 | | |
133 | 165 | | |
| 166 | + | |
| 167 | + | |
134 | 168 | | |
135 | | - | |
136 | 169 | | |
137 | 170 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
145 | 181 | | |
146 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
147 | 189 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
157 | 194 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
163 | 207 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | 208 | | |
168 | 209 | | |
169 | | - | |
| 210 | + | |
170 | 211 | | |
171 | 212 | | |
172 | | - | |
| 213 | + | |
173 | 214 | | |
174 | 215 | | |
175 | | - | |
176 | | - | |
| 216 | + | |
| 217 | + | |
177 | 218 | | |
178 | 219 | | |
179 | 220 | | |
| |||
0 commit comments