-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Enforce https in search #11337
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
Enforce https in search #11337
Changes from 4 commits
467da53
e78c0ec
0d6b4ed
0444d6a
83aee6d
f67fa22
06eb9b7
9d034a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from .._headers_mixin import HeadersMixin | ||
| from ._datasources_client import SearchDataSourcesClient | ||
| from ._indexes_client import SearchIndexesClient | ||
| from ._indexers_client import SearchIndexersClient | ||
| from ._skillsets_client import SearchSkillsetsClient | ||
| from ._synonym_maps_client import SearchSynonymMapsClient | ||
|
|
||
| if TYPE_CHECKING: | ||
| # pylint:disable=unused-import,ungrouped-imports | ||
| from typing import Any, Dict, List, Optional, Sequence | ||
| from azure.core.credentials import AzureKeyCredential | ||
|
|
||
|
|
||
| class SearchServiceClientBase(HeadersMixin): # pylint: disable=too-many-public-methods | ||
| """A client to interact with an existing Azure search service. | ||
|
|
||
| :param endpoint: The URL endpoint of an Azure search service | ||
| :type endpoint: str | ||
| :param credential: A credential to authorize search client requests | ||
| :type credential: ~azure.core.credentials import AzureKeyCredential | ||
|
|
||
| .. admonition:: Example: | ||
|
|
||
| .. literalinclude:: ../samples/sample_authentication.py | ||
| :start-after: [START create_search_service_with_key] | ||
| :end-before: [END create_search_service_with_key] | ||
| :language: python | ||
| :dedent: 4 | ||
| :caption: Creating the SearchServiceClient with an API key. | ||
|
||
| """ | ||
|
|
||
| _ODATA_ACCEPT = "application/json;odata.metadata=minimal" # type: str | ||
|
|
||
| def __init__(self, endpoint, credential): | ||
| # type: (str, AzureKeyCredential) -> None | ||
|
|
||
| try: | ||
| if endpoint.lower().startswith('http') and not endpoint.lower().startswith('https'): | ||
|
||
| raise ValueError("Bearer token authentication is not permitted for non-TLS protected (non-https) URLs.") | ||
| if not endpoint.lower().startswith('http'): | ||
| endpoint = "https://" + endpoint | ||
rakshith91 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| except AttributeError: | ||
| raise ValueError("Endpoint must be a string.") | ||
|
||
|
|
||
| self._endpoint = endpoint # type: str | ||
| self._credential = credential # type: AzureKeyCredential | ||
|
|
||
| def __repr__(self): | ||
| # type: () -> str | ||
| return "<SearchServiceClient [endpoint={}]>".format(repr(self._endpoint))[:1024] | ||
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.
Don't seem those imports are necessary here?
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 is pylint passing? ⭕
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.
removed these - but im shocked to see pylint not catching unused-import