-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Switch from security filter to built-in ACL enforcement #2771
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
Conversation
|
need to update docs |
|
need to update UX to remove security filter options |
Check Broken URLsWe have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue. Check the file paths and associated broken URLs inside them.
|
Check Country Locale in URLsWe have automatically detected added country locale to URLs in your files. Check the file paths and associated URLs inside them.
|
Check Broken URLsWe have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue. Check the file paths and associated broken URLs inside them.
|
|
|
||
| class AuthenticationHelper: | ||
| scope: str = "https://graph.microsoft.com/.default" | ||
| scope: str = "https://search.azure.com/.default" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change may make it slightly harder for people to extend the sample for arbitrary Graph API access, like to read emails, as I once demo'ed. Not sure who's actually doing that though. Just noting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see - unfortunately, we cannot request both scopes here. We can give guidance to do this twice though in the custom code
| ], | ||
| ) | ||
| ), | ||
| x_ms_query_source_authorization=access_token, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: Ensure that tests were added to verify that token is passed in for all calls to search()/retrieve()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do believe i wrote tests for this
|
|
||
| raise AuthError(error="Authorization header is expected", status_code=401) | ||
|
|
||
| def build_security_filters(self, overrides: dict[str, Any], auth_claims: dict[str, Any]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay code removal!
| # Only pass on the access token if access control is required | ||
| if self.require_access_control: | ||
| access_token = search_resource_access_token["access_token"] | ||
| auth_claims["access_token"] = access_token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come we don't need groups anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken care of by enforcement
https://learn.microsoft.com/en-us/azure/search/search-query-access-control-rbac-enforcement
| except AuthError as e: | ||
| logging.exception("Exception getting authorization information - " + json.dumps(e.error)) | ||
| if self.require_access_control and not self.enable_unauthenticated_access: | ||
| if not self.enable_unauthenticated_access: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remind me why this check can be simplified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should fail here regardless of if we require access control or not
The only reason we may succeed is if unauthenticated access was enabled
|
|
||
| 1. (Optional) **Allow unauthenticated access** | ||
| To allow unauthenticated users to use the app, even when access control is enforced, run the following command: | ||
| To allow unauthenticated users to use the app, run the following command: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You changed that comment, so does that mean access control is not enforced in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a user is not authenticated and access control is enabled, there's no way for them to see the global files anymore, we still need to pass in that access token.
You can put up a login screen though without access control, so the comment is updated here, correct
| - Select **Add permissions**. | ||
| - Select **API Permissions** in the left hand menu. The server app will use the `user_impersonation` permission from Azure AI Search to issue a token for security filtering on behalf of the logged in user. | ||
| - Select **Add a permission**, and then **APIs my organization uses**. | ||
| - Search for and select **Azure Cognitive Search**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it never got renamed to AI Search there aye?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Entra app didn't change, correct
|
|
||
|
|
||
| async def main(): | ||
| load_azd_env() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm how come I didn't need that before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was an oversight as we only tested this in the "full azd up" scenario where we loaded the env vars
tests/snapshots/test_app/test_chat_vision_user/auth_client0/result.json
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Purpose
Does this introduce a breaking change?
When developers merge from main and run the server, azd up, or azd deploy, will this produce an error?
If you're not sure, try it out on an old environment.
Note that global document access won't work the same, it will now work as the built-in access control does
Does this require changes to learn.microsoft.com docs?
This repository is referenced by this tutorial
which includes deployment, settings and usage instructions. If text or screenshot need to change in the tutorial,
check the box below and notify the tutorial author. A Microsoft employee can do this for you if you're an external contributor.
Type of change
Code quality checklist
See CONTRIBUTING.md for more details.
python -m pytest).python -m pytest --covto verify 100% coverage of added linespython -m mypyto check for type errorsruffandblackmanually on my code.