Repository navigation
gql-server: Introduce an endpoint /api/rest/userMetadata - #21258
gustavotrott merged 1 commit into
Conversation
…he client to fetch userdata info before creating a graphql connection. It is necessary to fetch props bbb_custom_style and bbb_custom_style_url.
WalkthroughThe changes introduce a new role Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Nginx
participant Backend
Client->>Nginx: GET /api/rest/userMetadata
Nginx->>Nginx: Check authorization
Nginx->>Backend: Proxy request to userMetadata query
Backend-->>Nginx: Return user metadata
Nginx-->>Client: Return user metadata response
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
bbb-graphql-server/metadata/rest_endpoints.yaml (1)
10-10: Consider adding a descriptive comment for the new endpoint.The comment field for the new
userMetadataendpoint is currently empty. Adding a brief description of the endpoint's purpose and usage would improve documentation and maintainability.Consider adding a comment like:
- comment: "Retrieves specific user metadata properties (bbb_custom_style and bbb_custom_style_url) for clients not in a meeting"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_user_metadata.yaml (1 hunks)
- bbb-graphql-server/metadata/query_collections.yaml (1 hunks)
- bbb-graphql-server/metadata/rest_endpoints.yaml (1 hunks)
- build/packages-template/bbb-graphql-middleware/graphql.nginx (1 hunks)
🔇 Additional comments not posted (4)
bbb-graphql-server/metadata/rest_endpoints.yaml (1)
11-18: LGTM! The new endpoint is well-structured and aligns with PR objectives.The
userMetadataendpoint is correctly defined and consistent with the existingclientSettingsendpoint structure. It properly specifies the GET method and uses the "allowed-queries" collection, which suggests appropriate access restrictions.To ensure the corresponding GraphQL query exists and is correctly implemented, please run the following script:
This script will help verify that the GraphQL query exists and includes the expected fields (bbb_custom_style and bbb_custom_style_url) as mentioned in the PR objectives.
bbb-graphql-server/metadata/query_collections.yaml (1)
11-18: LGTM! Consider adding parameter filters.The addition of the
userMetadataquery aligns well with the PR objectives. It correctly retrieves theparameterandvaluefields from theuser_metadataentity, which is suitable for key-value pair data.However, consider the following suggestions:
The PR mentions specifically retrieving
bbb_custom_styleandbbb_custom_style_url. You might want to add a filter to the query to retrieve only these specific parameters, enhancing security by limiting data exposure.Ensure that standard validations mentioned in the PR description are indeed applied to this query, particularly considering it doesn't currently have any filters.
To verify the application of standard validations, please run the following script:
This script will help ensure that appropriate validations are in place for the
user_metadatatable.bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_user_metadata.yaml (1)
21-32: Approve with suggestions for clarification and documentation.The new role
bbb_client_not_in_meetingis structurally sound and maintains consistent security measures with the existingbbb_clientrole. The use ofX-Hasura-MeetingIdandX-Hasura-UserIdin the filter conditions ensures proper authorization.However, I have a few suggestions:
The permissions for
bbb_client_not_in_meetingare identical tobbb_client. Could you clarify the necessity for a separate role? If there are distinctions in how these roles are used, it might be beneficial to document this.The role name suggests it's for clients not in a meeting, but the permissions are the same as for clients in a meeting. Could you explain the reasoning behind this naming convention and how it relates to the actual use case?
Consider adding a comment to explain the purpose and usage of this new role. This would help future maintainers understand the rationale behind its addition.
To ensure there are no unintended duplications or inconsistencies, let's verify the uniqueness of roles and their configurations:
This script will help us verify the uniqueness of roles across YAML files and identify any potential duplications or inconsistencies in role configurations.
✅ Verification successful
Approval confirmed: New role
bbb_client_not_in_meetingdoes not introduce naming conflicts.The verification process has confirmed that the new role
bbb_client_not_in_meetingdoes not introduce any naming conflicts with existing roles in the system. This supports the approval of the change from a role uniqueness perspective.However, I would like to reiterate the suggestions from the initial review:
While the role name is unique, its permissions are identical to the existing
bbb_clientrole. Consider documenting the specific use case or scenario that necessitates this separate role to aid future maintenance and understanding.The role name suggests it's for clients not in a meeting, but the permissions are the same as for clients in a meeting. It would be beneficial to clarify the reasoning behind this naming convention and how it relates to the actual use case.
Adding a comment in the YAML file to explain the purpose and usage of this new role would greatly help future maintainers understand the rationale behind its addition.
These suggestions aim to improve the overall clarity and maintainability of the role structure in your system.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for unique roles and their configurations in YAML files # Test: List all roles and their configurations echo "Roles and their configurations:" fd -e yaml | xargs yq '.select_permissions[] | {"role": .role, "columns": .permission.columns, "filter": .permission.filter}' # Test: Check for duplicate role names echo -e "\nDuplicate role names (if any):" fd -e yaml | xargs yq '.select_permissions[].role' | sort | uniq -dLength of output: 421
Script:
#!/bin/bash # Description: Check for unique roles and their configurations in YAML files without using yq # List all YAML files yaml_files=$(fd -e yaml) # Extract roles and their configurations echo "Roles and their configurations:" for file in $yaml_files; do echo "File: $file" awk '/role:/ {role=$2} /columns:/ {cols=""} /- parameter/ {cols=cols " parameter"} /- value/ {cols=cols " value"} /filter:/ {filt=""} /_and:/ {filt="_and"} /meetingId:/ {filt=filt " meetingId=_eq"} /userId:/ {filt=filt " userId=_eq"} END {print " Role: " role ", Columns:" cols ", Filter:" filt}' "$file" done # Check for duplicate role names echo -e "\nDuplicate role names (if any):" for file in $yaml_files; do awk '/role:/ {print $2}' "$file" done | sort | uniq -dLength of output: 71752
Script:
#!/bin/bash # Description: Accurately extract roles and their configurations from YAML files and identify duplicates # List all YAML files yaml_files=$(fd -e yaml) # Initialize temporary files to store roles and configurations echo "Roles and their configurations:" > roles_configurations.txt # Extract roles, columns, and filters using grep and sed for file in $yaml_files; do echo "File: $file" >> roles_configurations.txt # Extract role role=$(grep -E '^\s*role:\s*\S+' "$file" | sed -e 's/^\s*role:\s*//') # Extract columns columns=$(grep -A2 'columns:' "$file" | grep -E '^\s*-\s*\S+' | awk '{print $2}' | paste -sd ", " -) # Extract filters filters=$(grep -A4 'filter:' "$file" | grep -E '^\s*-|\s*_and:' | sed -e 's/^\s*- //;s/^\s*_and://') echo " Role: $role, Columns: $columns, Filter: $filters" >> roles_configurations.txt done # Display the roles and their configurations cat roles_configurations.txt # Check for duplicate role names echo -e "\nDuplicate role names (if any):" >> roles_configurations.txt grep -E '^\s*role:\s*\S+' $yaml_files | sed -e 's/^\s*role:\s*//' | sort | uniq -d >> roles_configurations.txt # Display duplicates cat roles_configurations.txtLength of output: 98195
Script:
#!/bin/bash # Description: Extract all non-empty role names from YAML files and identify duplicates # List all YAML files yaml_files=$(fd -e yaml) # Extract role names, remove empty entries, sort them, and count duplicates echo "Extracting role names and identifying duplicates..." grep -hE '^\s*role:\s*\S+' $yaml_files | sed -e 's/^\s*role:\s*//' | grep -v '^$' | sort | uniq -c | awk '$1 > 1 {print "Duplicate Role \"" $2 "\" found " $1 " times."}' # If no duplicates are found, indicate as such if ! grep -hE '^\s*role:\s*\S+' $yaml_files | sed -e 's/^\s*role:\s*//' | grep -v '^$' | sort | uniq -c | awk '$1 > 1 {exit 1}'; then echo "No duplicate roles found." fiLength of output: 20778
Script:
#!/bin/bash # Description: Extract all non-empty role names from YAML files and identify duplicates # List all YAML files yaml_files=$(fd -e yaml) # Extract role names, remove empty entries, sort them, and count duplicates echo "Extracting role names and identifying duplicates..." duplicates=$(grep -hE '^\s*role:\s*\S+' $yaml_files | sed -e 's/^\s*role:\s*//' | grep -v '^$' | sort | uniq -c | awk '$1 > 1 {print "Duplicate Role \"" $2 "\" found " $1 " times."}') # Check if duplicates are found if [ -n "$duplicates" ]; then echo "$duplicates" else echo "No duplicate roles found." fiLength of output: 13974
build/packages-template/bbb-graphql-middleware/graphql.nginx (1)
30-39: LGTM! The new endpoint is well-implemented.The new location block for
/api/rest/userMetadatais correctly implemented with proper authorization checks and proxy settings. It aligns well with the existing configuration style and the PR objectives.Consider caching for performance optimization.
Unlike the
/api/rest/clientSettingsendpoint, this new endpoint doesn't include caching directives. If the user metadata is not expected to change frequently, consider adding caching to improve performance.If caching is appropriate, you could add the following directives:
proxy_cache user_metadata_cache; proxy_cache_key "$uri|$meeting_id"; proxy_cache_use_stale updating; proxy_cache_valid 15m; # Adjust the cache duration as needed proxy_cache_lock on; add_header X-Cached $upstream_cache_status;Verify the role-based access control.
The PR objectives mention granting the
bbb_client_not_in_meetingrole permission to access user metadata. Ensure that this role-based access control is implemented in the backend (Hasura) or in thecheckGraphqlAuthorizationendpoint.To verify the role-based access control, you can run the following script:
✅ Verification successful
Role-based access control confirmed.
The
bbb_client_not_in_meetingrole is correctly defined in multiple configuration files, ensuring proper permission settings as per the PR objectives.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for the presence of the 'bbb_client_not_in_meeting' role in the Hasura configuration # Test: Search for the 'bbb_client_not_in_meeting' role in Hasura configuration files rg --type yaml 'bbb_client_not_in_meeting' -g 'metadata/databases/*/tables/*.yaml'Length of output: 231
Script:
#!/bin/bash # Description: Check for the presence of the 'bbb_client_not_in_meeting' role in all YAML configuration files # Test: Search for the 'bbb_client_not_in_meeting' role across the entire codebase in YAML files rg --type yaml 'bbb_client_not_in_meeting'Length of output: 872
|
@JoVictorNunes will review it while he implements his task that relies on this PR. |
Automated tests Summary✅ All the CI tests have passed! |



This pull request introduces a new GET endpoint
/api/rest/userMetadata, enabling clients to fetchuserdataproperties such asbbb_custom_styleandbbb_custom_style_urlbefore initiating a GraphQL connection.Provided by Hasura, this endpoint includes all standard validations akin to GraphQL queries.
Additionally, it grants the
bbb_client_not_in_meetingrole (users that haven't join) permission to accessuser_metadata.Query used internally:
Example of response:
{ "data": { "user_metadata": [ { "parameter": "bbb_client_title", "value": "test" } ] } }Summary by CodeRabbit
New Features
bbb_client_not_in_meetingfor enhanced user access control.userMetadataquery to retrieve user-specific metadata.Improvements
These updates provide more granular control and improved access to user data in various scenarios.