-
Notifications
You must be signed in to change notification settings - Fork 5
feat: precomputed scopes #2719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: precomputed scopes #2719
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,16 +71,24 @@ | |
| return token.(string), nil | ||
| } | ||
|
|
||
| rlsPayload, err := GetRLSPayload(ctx.WithUser(user)) | ||
| if err != nil { | ||
| return "", ctx.Oops().Wrap(err) | ||
| } | ||
|
|
||
| role := config.Postgrest.DBRole | ||
| if rlsPayload.Disable && config.Postgrest.DBRoleBypass != "" { | ||
| role = config.Postgrest.DBRoleBypass | ||
| } | ||
|
Comment on lines
+74
to
+82
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build failure: The pipeline failures confirm that The refactored logic is correct:
This aligns with the changes in 🧰 Tools🪛 GitHub Actions: Build[error] 80-81: Build failed: config.Postgrest.DBRoleBypass is undefined in tokens.go (lines 80-81). Go code references a field that no longer exists in the duty API. 🪛 GitHub Check: lint[failure] 81-81: [failure] 80-80: 🤖 Prompt for AI Agents |
||
|
|
||
| // Postgrest makes this jwt available as a session parameter inside postgres. | ||
| // We inject the rls payload here and then access it inside postgres using request.jwt.claims parameter. | ||
| claims := jwt.MapClaims{ | ||
| "role": config.Postgrest.DBRole, | ||
| "role": role, | ||
| "id": user.ID.String(), | ||
| } | ||
|
|
||
| if rlsPayload, err := GetRLSPayload(ctx.WithUser(user)); err != nil { | ||
| return "", ctx.Oops().Wrap(err) | ||
| } else if jwtClaim := rlsPayload.JWTClaims(); jwtClaim != nil { | ||
| if jwtClaim := rlsPayload.JWTClaims(); jwtClaim != nil { | ||
| claims = collections.MergeMap(claims, jwtClaim) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build failure:
DBRoleBypassis undefined onPostgrestConfig.The static analysis and pipeline failures confirm that
dutyAPI.DefaultConfig.Postgrest.DBRoleBypassdoes not exist in the current duty version. This field must be added to the duty package before this code will compile.The logic itself is sound: when RLS is disabled, set a local role for the transaction to ensure proper database access. However, the implementation depends on API that doesn't exist yet in the pinned duty version.
🧰 Tools
🪛 GitHub Actions: CodeQL
[error] 80-80: Go compile error: undefined field DBRoleBypass in PostgrestConfig (duty API). The field DBRoleBypass does not exist on type 'github.com/flanksource/duty/api'.PostgrestConfig.
🪛 GitHub Actions: Lint
[error] 80-80: auth/rls.go:80:44: dutyAPI.DefaultConfig.Postgrest.DBRoleBypass undefined (type "github.com/flanksource/duty/api'.PostgrestConfig has no field or method DBRoleBypass). GolangCI-Lint: run command failed: golangci-lint run --verbose --max-same-issues=0 --max-issues-per-linter=0
🪛 GitHub Actions: Test
[error] 80-80: dutyAPI.DefaultConfig.Postgrest.DBRoleBypass undefined (type "github.com/flanksource/duty/api".PostgrestConfig has no field or method DBRoleBypass)
🪛 GitHub Check: lint
[failure] 80-80:
dutyAPI.DefaultConfig.Postgrest.DBRoleBypass undefined (type "github.com/flanksource/duty/api".PostgrestConfig has no field or method DBRoleBypass)
🤖 Prompt for AI Agents