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

User username as VM username rather than random ID #3770

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

marrobi
Copy link
Member

@marrobi marrobi commented Oct 27, 2023

Fixes #1148 #3693

This pull request includes several changes to the api_app to enhance user details handling and update various components to utilize these details. The most important changes include adding the username field to the User model, updating the Resource model to include user details, and modifying the authentication service to handle the new user details.

@marrobi marrobi changed the title PoC with Windows VM User username as VM username rather than random ID Oct 27, 2023
@github-actions
Copy link

github-actions bot commented Oct 27, 2023

Unit Test Results

596 tests   596 ✅  6s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit 1be0132.

♻️ This comment has been updated with latest results.

@marrobi
Copy link
Member Author

marrobi commented Feb 28, 2024

@tamirkamara @damoodamoo welcome your thoughts on this from a design perspective, got a few asks for this. Think should have a "user object":

"user": {
 "name": "blah",
 "email": "blah",
 "username": "blah" 
}

In the payload rather than how I've done it in this PR? The RP would need to understand where to look.

Copy link
Contributor

@tanya-borisova tanya-borisova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I think it's fine without a user object, as this avoids some code in the RP that would have to unpack it

@damoodamoo
Copy link
Member

I would say it would be nicer to pass a user object rather than as individual fields, since it will only grow over time. But - not a big deal and agree with @tanya-borisova that it would mean more code in the RP.

@marrobi
Copy link
Member Author

marrobi commented Oct 18, 2024

/test-extended

Copy link

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/11401103181 (with refid 323e78ec)

(in response to this comment from @marrobi)

@marrobi marrobi marked this pull request as ready for review December 13, 2024 16:18
@marrobi marrobi requested a review from Copilot December 13, 2024 16:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 11 out of 25 changed files in this pull request and generated 1 comment.

Files not reviewed (14)
  • templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/linuxvm.tf: Language not supported
  • templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/locals.tf: Language not supported
  • templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/outputs.tf: Language not supported
  • templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/variables.tf: Language not supported
  • api_app/tests_ma/test_service_bus/test_resource_request_sender.py: Evaluated as low risk
  • api_app/tests_ma/test_services/test_aad_access_service.py: Evaluated as low risk
  • resource_processor/_version.py: Evaluated as low risk
  • api_app/tests_ma/test_api/test_routes/test_workspaces.py: Evaluated as low risk
  • api_app/tests_ma/test_api/conftest.py: Evaluated as low risk
  • api_app/tests_ma/conftest.py: Evaluated as low risk
  • api_app/tests_ma/test_models/test_resource.py: Evaluated as low risk
  • resource_processor/tests_rp/test_logging.py: Evaluated as low risk
  • api_app/models/domain/authentication.py: Evaluated as low risk
  • CHANGELOG.md: Evaluated as low risk
Comments suppressed due to low confidence (1)

api_app/services/aad_authentication.py:276

  • The new 'username' field in the '_get_users_inc_groups_from_response' method is not covered by tests.
+                user_username = user_data["body"]["userPrincipalName"]

updatedWhen: float = 0

def get_resource_request_message_payload(self, operation_id: str, step_id: str, action: RequestAction) -> dict:
payload = {
"operationId": operation_id,
"stepId": step_id,
"action": action,
"user": {
Copy link
Preview

Copilot AI Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'user' field is Optional[User], but there is no null check before accessing its attributes. This could lead to an AttributeError if 'user' is None. Add a null check before accessing 'user' attributes.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

VM username should be the users username from access token, rather than a random one.
3 participants