Repository navigation
Add VIEWER role, document access control, and validate signed filter values - #6
Merged
Merged
Conversation
Basedash accepts ADMIN, MEMBER, and VIEWER in the SSO role claim; the type only allowed the first two. Document the live role and groups claim behavior in the types. createDashboardFilterToken now rejects values whose rendered text contains ' " ` \ ; -- or /*, the free-text check Basedash applies to viewer-supplied values but not to signed ones, before signing. Co-authored-by: Max Musing <MaxMusing@users.noreply.github.com>
State that components, hide options, and the sidebar are presentation only, document the live role and groups claim behavior, recommend VIEWER and server-controlled groups for least privilege, and warn that signed filter values are rendered into chart SQL as raw text. Co-authored-by: Max Musing <MaxMusing@users.noreply.github.com>
Co-authored-by: Max Musing <MaxMusing@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes the SDK's types and docs match how Basedash actually enforces access. It also adds one validation step before shared-dashboard filter tokens are signed.
VIEWERrole.BasedashRoleis now"ADMIN" | "MEMBER" | "VIEWER". Basedash's SSO claim schema already accepts all three (z.enum(MemberRole)), but the SDK type only allowed two. The role descriptions come from Basedash's role options.VIEWERis view-only: it can open resources shared with it, but cannot create, edit, or chat.groupsdocs. The "Reserved for future group synchronization" comment was wrong, so this PR replaces it with the live behavior:roleandgroupsare not applied when the email belongs to a verified Basedash account that is already an active member of the organization.CONTRACT.mdnow say plainly that the component you choose, thehide*options,hideSidebar, andinitialPageare presentation only. A new "Access control" section points integrators to a signedVIEWERrole and server-controlled groups for least privilege.createDashboardFilterTokennow throws before signing if a value contains',",`,\,;,--, or/*:,, numbers and booleans withString()).isAllowedPublicVariableValue), and the only part of that check that doesn't depend on the variable's declared type.Behavior change
Integrators who currently sign values containing those sequences (for example, a company name with an apostrophe) will now get a
TypeErrorinstead of a token. The changeset is markedminorfor that reason. The SDK is also stricter than Basedash in one case: aLISTdropdown option that itself contains one of these sequences is accepted from a viewer, but rejected by the SDK.CONTRACT.mddocuments this.Scope
createDashboardFilterToken.Testing
pnpm checkpasses: typecheck, 49 tests, build, publint, and attw. The node10 resolution rows are ignored, as onmain.tests/server.test.ts:VIEWERtoken signs and verifies.SignJWT.prototype.signconfirms nothing is signed.,).src/server/index.ts, 9 of the new tests fail; with this change they pass.examples/nextjs,examples/vite) typecheck against the local SDK source. The Next.js token route was also run against the built package with a randomly generated throwaway secret that was never printed or stored.