Skip to content
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

Authorization: Add READ_ABOUT privilege for being able to see information about space; remove anonymousReadAccess #4782

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

techsmyth
Copy link
Member

@techsmyth techsmyth commented Dec 13, 2024

added new privilege: READ_ABOUT

Tidied up credential rules related to space admins, removing one rule

Added in credential rule to assign READ_ABOUT to all members of parent space for Space itself and also for Context + Profile

Added privilege rule so that if a user has READ then also gets READ_ABOUT, for Space, Context + Profile

Updated field resolvers on Space to check for READ_ABOUT (previously were simply left without authorization checks)

Updated lookup of context, profiles + spaces to check for READ_ABOUT

Triggered by work on READ_ABOUT...where we will need more control that the simple flag that controls READ access.

=======
Add new global credential GLOBAL_ANONYMOUS
Assign this credential to AgentInfos that are representing anonymous usage

Removed anonymousReadAccess flag from authorization policy
Added utility method to assign a credential rule for anonymous usage with a specified privilege to an authorization policy

Updated Space sorting to use privacy mode (public/private) instead of anonymousReadAccess (basically fixing a potential bug). Potentially the new setup is also faster.

Reworked handling of AgentInfo to bring the creation / updating of this data structure to be in one place

Client is already updated not to use anonymousReadAccess flag.

Initial results:
image

Todo:

  • not yet tested / run
  • check what updates the client needs
  • check for edge cases by having test suites passing; there may be cases where something is over ruled in the child previously which the new setup will not cover
  • update unit tests on Space: they were using anonymousReadAccess but now should be using settings.privacy.mode = Public/Private
  • see if can easily share the logic for generating an AgentInfo for anonymous user requests, currently duplicated 3x. Problems with module dependency in one case, plus second case where have functional vs service usage.
  • check with light testing the impact this has on performance; risk is that it is heavier
  • test test test

Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

Warning

Rate limit exceeded

@techsmyth has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 24 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 1a249ca and 71ab7c0.

📒 Files selected for processing (50)
  • src/common/constants/authorization/credential.rule.constants.ts (1 hunks)
  • src/common/constants/authorization/policy.rule.constants.ts (1 hunks)
  • src/common/enums/authorization.credential.ts (1 hunks)
  • src/common/enums/authorization.privilege.ts (1 hunks)
  • src/core/authentication.agent.info/agent.info.metadata.ts (1 hunks)
  • src/core/authentication.agent.info/agent.info.module.ts (1 hunks)
  • src/core/authentication.agent.info/agent.info.service.ts (1 hunks)
  • src/core/authentication.agent.info/agent.info.ts (1 hunks)
  • src/core/authentication/authentication.module.ts (1 hunks)
  • src/core/authentication/authentication.service.ts (5 hunks)
  • src/core/authorization/authorization.service.ts (4 hunks)
  • src/core/authorization/graphql.guard.ts (3 hunks)
  • src/domain/access/role-set/role.set.service.authorization.ts (0 hunks)
  • src/domain/collaboration/innovation-flow/innovation.flow.service.authorization.ts (1 hunks)
  • src/domain/common/authorization-policy/authorization.policy.entity.ts (0 hunks)
  • src/domain/common/authorization-policy/authorization.policy.interface.ts (0 hunks)
  • src/domain/common/authorization-policy/authorization.policy.service.ts (5 hunks)
  • src/domain/common/profile/profile.service.authorization.ts (2 hunks)
  • src/domain/community/community-guidelines/community.guidelines.service.authorization.ts (2 hunks)
  • src/domain/community/community/community.service.authorization.ts (1 hunks)
  • src/domain/community/organization/organization.service.authorization.ts (1 hunks)
  • src/domain/community/user/user.service.authorization.ts (1 hunks)
  • src/domain/community/user/user.service.ts (0 hunks)
  • src/domain/community/virtual-contributor/virtual.contributor.service.authorization.ts (1 hunks)
  • src/domain/context/context/context.service.authorization.ts (2 hunks)
  • src/domain/innovation-hub/innovation.hub.service.authorization.ts (1 hunks)
  • src/domain/space/account/account.service.authorization.ts (3 hunks)
  • src/domain/space/space/space.resolver.fields.ts (3 hunks)
  • src/domain/space/space/space.service.authorization.ts (10 hunks)
  • src/domain/space/space/space.service.spec.ts (2 hunks)
  • src/domain/storage/document/document.service.authorization.ts (2 hunks)
  • src/domain/storage/storage-aggregator/storage.aggregator.service.authorization.ts (2 hunks)
  • src/library/library/library.service.authorization.ts (2 hunks)
  • src/migrations/1734708463666-authAnonymousReadAccess.ts (1 hunks)
  • src/platform/forum-discussion/discussion.service.authorization.ts (1 hunks)
  • src/platform/licensing/credential-based/licensing-framework/licensing.framework.service.authorization.ts (1 hunks)
  • src/platform/platform/platform.service.authorization.ts (2 hunks)
  • src/services/ai-server/ai-server/ai.server.service.authorization.ts (0 hunks)
  • src/services/api/lookup/lookup.resolver.fields.ts (1 hunks)
  • src/services/api/roles/util/group.credentials.by.entity.ts (3 hunks)
  • src/services/external/excalidraw-backend/middlewares/socket.data.init.middleware.ts (1 hunks)
  • src/services/file-integration/file.integration.service.ts (1 hunks)
  • src/services/whiteboard-integration/whiteboard.integration.module.ts (1 hunks)
  • src/services/whiteboard-integration/whiteboard.integration.service.ts (3 hunks)
  • test/data/agent.json (0 hunks)
  • test/data/organization.json (0 hunks)
  • test/data/space.json (0 hunks)
  • test/data/subspace.json (0 hunks)
  • test/data/subsubspace.json (0 hunks)
  • test/data/user.json (0 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@valentinyanakiev
Copy link
Member

valentinyanakiev commented Dec 13, 2024

added new privilege: READ_ABOUT

Tidied up credential rules related to space admins, removing one rule

Added in credential rule to assign READ_ABOUT to all members of parent space for Space itself and also for Context + Profile

Added privilege rule so that if a user has READ then also gets READ_ABOUT, for Space, Context + Profile

Updated field resolvers on Space to check for READ_ABOUT (previously were simply left without authorization checks)

Updated lookup of context, profiles + spaces to check for READ_ABOUT

To do:

  • not yet tested / run
  • check what updates the client needs

I have different design / considerations that in my opinion is better / will require less changes:
https://alkem.io/building-alkemio-org/challenges/technicaldesigns-9853/collaboration/readingaboutprivileges

It also follows the pattern used in other places where we assign a specific credential to the parent and then we have a privilege rule to 'translate' it to the child.

… lookup to check for READ; added privilege rule to Profile, Context + Document to map READ_ABOUT to READ; made addition of READ_ABOUT on Space cascade
…d credential definition; added Global Anonymous credential
@techsmyth techsmyth changed the title Add READ_ABOUT privilege for being able to see information about space Authorization: Add READ_ABOUT privilege for being able to see information about space Dec 14, 2024
@techsmyth techsmyth changed the title Authorization: Add READ_ABOUT privilege for being able to see information about space Authorization: Add READ_ABOUT privilege for being able to see information about space; remove anonymousReadAccess Dec 20, 2024
@techsmyth techsmyth marked this pull request as ready for review December 21, 2024 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants