Skip to content

Commit 028c2fe

Browse files
committed
wip
1 parent 1f4268c commit 028c2fe

File tree

18 files changed

+123
-30
lines changed

18 files changed

+123
-30
lines changed

doc/env_vars.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ These config vars enable and configure browser security response headers from th
197197
| `LRSQL_SEC_HEAD_CROSS_DOMAIN` | `secHeadCrossDomain` | `X-Permitted-Cross-Domain-Policies` | `none` |
198198
| `LRSQL_SEC_HEAD_CONTENT` | `secHeadContent` | `Content-Security-Policy` | `object-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' 'strict-dynamic' https: http:;` |
199199

200+
#### Proxy Settings
201+
202+
| Env Var | Config | Description | Default |
203+
| --------------------------------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
204+
| `LRSQL_AUTH_BY_CRED_Id` | `authByCredId` | Authorization workaround for when lrsql is running behind a proxy | `false` |
205+
200206
#### Admin Features
201207

202208
| Env Var | Config | Description | Default |

resources/lrsql/config/prod/default/webserver.edn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@
4545
:oidc-enable-local-admin #boolean #or [#env LRSQL_OIDC_ENABLE_LOCAL_ADMIN false]
4646
:enable-clamav #boolean #or [#env LRSQL_ENABLE_CLAMAV false]
4747
:clamav-host #or [#env LRSQL_CLAMAV_HOST "localhost"]
48-
:clamav-port #long #or [#env LRSQL_CLAMAV_PORT 3310]}
48+
:clamav-port #long #or [#env LRSQL_CLAMAV_PORT 3310]
49+
:auth-by-cred-id #boolean #or [#env LRSQL_AUTH_BY_CRED_ID false]
50+
}

resources/lrsql/config/test/default/webserver.edn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@
3535
:oidc-enable-local-admin false
3636
:enable-clamav false
3737
:clamav-host "localhost"
38-
:clamav-port 3310}
38+
:clamav-port 3310
39+
:auth-by-cred-id false ;may need to be set to true if lrsql behind proxy
40+
}

src/db/postgres/lrsql/postgres/record.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@
221221
(query-credential-ids tx input))
222222
(-query-credential-scopes [_ tx input]
223223
(query-credential-scopes tx input))
224+
(-query-credential-by-id [_ tx input]
225+
(query-credential-by-id tx input))
224226

225227
bp/BackendIOSetter
226228
(-set-read! [_]

src/db/postgres/lrsql/postgres/sql/query.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ WHERE oidc_issuer IS NULL;
286286
-- :command :query
287287
-- :result :many
288288
-- :doc Query all credentials associated with `:account-id`.
289-
SELECT api_key, secret_key FROM lrs_credential
289+
SELECT id, api_key, secret_key FROM lrs_credential
290290
WHERE account_id = :account-id;
291291

292292
-- :name query-credential-ids
@@ -305,6 +305,13 @@ SELECT scope FROM credential_to_scope
305305
WHERE api_key = :api-key
306306
AND secret_key = :secret-key;
307307

308+
-- :name query-credential-by-id
309+
-- :command :query
310+
-- :result :one
311+
-- :doc Get credential by id
312+
SELECT id, api_key, secret_key, account_id FROM lrs_credential
313+
WHERE id = :id;
314+
308315
/* LRS Status */
309316

310317
-- :name query-statement-count

src/db/sqlite/lrsql/sqlite/record.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@
262262
(query-credential-ids tx input))
263263
(-query-credential-scopes [_ tx input]
264264
(query-credential-scopes tx input))
265+
(-query-credential-by-id [_ tx input]
266+
(query-credential-by-id tx input))
265267

266268
bp/BackendIOSetter
267269
(-set-read! [_]

src/db/sqlite/lrsql/sqlite/sql/query.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ WHERE oidc_issuer IS NULL
262262
-- :command :query
263263
-- :result :many
264264
-- :doc Query all credentials associated with `:account-id`.
265-
SELECT api_key, secret_key FROM lrs_credential
265+
SELECT id, api_key, secret_key FROM lrs_credential
266266
WHERE account_id = :account-id
267267

268268
-- :name query-credential-ids
@@ -281,6 +281,13 @@ SELECT scope FROM credential_to_scope
281281
WHERE api_key = :api-key
282282
AND secret_key = :secret-key
283283

284+
-- :name query-credential-by-id
285+
-- :command :query
286+
-- :result :one
287+
-- :doc Get credential by id
288+
SELECT id, api_key, secret_key, account_id FROM lrs_credential
289+
WHERE id = :id
290+
284291
/* LRS Status */
285292

286293
-- :name query-statement-count

src/dev/lrsql/user.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
[next.jdbc :as jdbc]
66
[com.yetanalytics.lrs.protocol :as lrsp]
77
[lrsql.admin.protocol :as adp]
8-
[lrsql.util :as u]
98
[lrsql.util.actor :as a-util]))
109

1110

src/main/lrsql/admin/interceptors/ui.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
no-val?
3636
no-val-logout-url
3737
stmt-get-max
38-
proxy-path]
38+
proxy-path
39+
auth-by-cred-id]
3940
:or {enable-admin-delete-actor false
4041
enable-admin-status false
4142
enable-reactions false
@@ -61,7 +62,8 @@
6162
:no-val? no-val?
6263
:admin-language-code admin-language-code
6364
:custom-language (custom-language-map)
64-
:stmt-get-max stmt-get-max}
65+
:stmt-get-max stmt-get-max
66+
:auth-by-cred-id auth-by-cred-id}
6567
(and no-val?
6668
(not-empty no-val-logout-url))
6769
(assoc :no-val-logout-url no-val-logout-url))

src/main/lrsql/admin/routes.clj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@
342342
enable-reaction-routes
343343
oidc-interceptors
344344
oidc-ui-interceptors
345-
head-opts]
345+
head-opts
346+
auth-by-cred-id]
346347
:or {oidc-interceptors []
347348
oidc-ui-interceptors []
348349
enable-account-routes true}}
@@ -373,7 +374,9 @@
373374
:proxy-path proxy-path
374375
:stmt-get-max stmt-get-max
375376
:enable-admin-delete-actor enable-admin-delete-actor
376-
:admin-language-code admin-language-code}))
377+
:admin-language-code admin-language-code
378+
:auth-by-cred-id auth-by-cred-id
379+
}))
377380
(when enable-admin-status
378381
(admin-status-routes
379382
common-interceptors-oidc secret leeway no-val-opts))

0 commit comments

Comments
 (0)