Skip to content

Commit

Permalink
[SDK/CLI] Handle user name for non-msft tenant (#1671)
Browse files Browse the repository at this point in the history
# Description

Please add an informative description that covers that changes made by
the pull request and link all relevant issues.

# All Promptflow Contribution checklist:
- [ ] **The pull request does not introduce [breaking changes].**
- [ ] **CHANGELOG is updated for new features, bug fixes or other
significant changes.**
- [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).**
- [ ] **Create an issue and link to the pull request to get dedicated
review from promptflow team. Learn more: [suggested
workflow](../CONTRIBUTING.md#suggested-workflow).**

## General Guidelines and Best Practices
- [ ] Title of the pull request is clear and informative.
- [ ] There are a small number of commits, each of which have an
informative message. This means that previously merged commits do not
appear in the history of the PR. For more information on cleaning up the
commits in your PR, [see this
page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).

### Testing Guidelines
- [ ] Pull request includes test coverage for the included changes.
  • Loading branch information
0mza987 authored Jan 5, 2024
1 parent c4a7cbf commit c1efe0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/promptflow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
- Fix loose flow path validation for run schema.
- Fix "Without Import Data" in run visualize page results from invalid JSON value (`-Infinity`, `Infinity` and `NaN`).

### Improvements

- [SDK/CLI] For `pfazure flow create` used by non-msft tenant user, use user name instead of user object id in the remote flow folder path. (e.g. `Users/<user-name>/promptflow`).

## 1.3.0 (2023.12.27)

### Features Added
Expand Down
4 changes: 2 additions & 2 deletions src/promptflow/promptflow/azure/_utils/gerneral.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def is_arm_id(obj) -> bool:


def get_user_alias_from_credential(credential):
token = credential.get_token("https://storage.azure.com/.default").token
token = credential.get_token("https://management.azure.com/.default").token
decode_json = jwt.decode(token, options={"verify_signature": False, "verify_aud": False})
try:
email = decode_json["upn"]
email = decode_json.get("upn", decode_json.get("email", None))
return email.split("@")[0]
except Exception:
# use oid when failed to get upn, e.g. service principal
Expand Down

0 comments on commit c1efe0a

Please sign in to comment.