-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[App Config] az appconfig: Add anonymous auth mode
#32639
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
base: dev
Are you sure you want to change the base?
Changes from all commits
c943ffa
7b55e08
8c7d877
934870a
8be2530
5ed88f6
50e6874
c4dca23
8009239
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 |
|---|---|---|
|
|
@@ -164,11 +164,12 @@ def load_arguments(self, _): | |
| c.argument('top', arg_type=top_arg_type) | ||
| c.argument('all_', options_list=['--all'], action='store_true', help="List all items.") | ||
| c.argument('fields', arg_type=fields_arg_type) | ||
| c.argument('endpoint', help='If auth mode is "login", provide endpoint URL of the App Configuration store. The endpoint can be retrieved using "az appconfig show" command. You can configure the default endpoint using `az configure --defaults appconfig_endpoint=<endpoint>`', configured_default='appconfig_endpoint') | ||
| c.argument('auth_mode', arg_type=get_enum_type(['login', 'key']), configured_default='appconfig_auth_mode', validator=validate_auth_mode, | ||
| c.argument('endpoint', help='If auth mode is "login" or "anonymous", provide endpoint URL of the App Configuration store. The endpoint can be retrieved using "az appconfig show" command. You can configure the default endpoint using `az configure --defaults appconfig_endpoint=<endpoint>`', configured_default='appconfig_endpoint') | ||
| c.argument('auth_mode', arg_type=get_enum_type(['login', 'key', 'anonymous']), configured_default='appconfig_auth_mode', validator=validate_auth_mode, | ||
| help='This parameter can be used for indicating how a data operation is to be authorized. ' + | ||
| 'If the auth mode is "key", provide connection string or store name and your account access keys will be retrieved for authorization. ' + | ||
| 'If the auth mode is "login", provide the `--endpoint` or `--name` and your "az login" credentials will be used for authorization. ' + | ||
| 'If the auth mode is "anonymous", provide the `--endpoint` that will be used for authorization. Anonymous mode only allows HTTP endpoints. ' + | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would update this slightly to say the following:
@mrm9084 thoughts? |
||
| 'You can configure the default auth mode using `az configure --defaults appconfig_auth_mode=<auth_mode>`. ' + | ||
| 'For more information, see https://learn.microsoft.com/azure/azure-app-configuration/concept-enable-rbac') | ||
|
|
||
|
|
@@ -256,7 +257,7 @@ def load_arguments(self, _): | |
| c.argument('src_label', help="Only keys with this label in source AppConfig will be imported. If no value specified, import keys with null label by default. Support star sign as filters, for instance * means all labels, abc* means labels with abc as prefix.") | ||
| c.argument('preserve_labels', arg_type=get_three_state_flag(), help="Flag to preserve labels from source AppConfig. This argument should NOT be specified along with --label.") | ||
| c.argument('src_endpoint', help='If --src-auth-mode is "login", provide endpoint URL of the source App Configuration store.') | ||
| c.argument('src_auth_mode', arg_type=get_enum_type(['login', 'key']), | ||
| c.argument('src_auth_mode', arg_type=get_enum_type(['login', 'key', 'anonymous']), | ||
| help='Auth mode for connecting to source App Configuration store. For details, refer to "--auth-mode" argument.') | ||
| c.argument('src_snapshot', validator=validate_snapshot_import, | ||
| help='Import all keys in a given snapshot of the source App Configuration store. If no snapshot is specified, the keys currently in the store are imported based on the specified key and label filters.') | ||
|
|
@@ -299,7 +300,7 @@ def load_arguments(self, _): | |
| c.argument('dest_label', help="Exported KVs will be labeled with this destination label. If neither --dest-label nor --preserve-labels is specified, will assign null label.") | ||
| c.argument('preserve_labels', arg_type=get_three_state_flag(), help="Flag to preserve labels from source AppConfig. This argument should NOT be specified along with --dest-label.") | ||
| c.argument('dest_endpoint', help='If --dest-auth-mode is "login", provide endpoint URL of the destination App Configuration store.') | ||
| c.argument('dest_auth_mode', arg_type=get_enum_type(['login', 'key']), | ||
| c.argument('dest_auth_mode', arg_type=get_enum_type(['login', 'key', 'anonymous']), | ||
| help='Auth mode for connecting to the destination App Configuration store. For details, refer to "--auth-mode" argument.') | ||
| c.argument('dest_tags', nargs="*", help="Exported KVs and feature flags will be assigned with these tags. If no tags are specified, exported KVs and features will retain existing tags. Support space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.") | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,8 +19,10 @@ | |||||||||||||||||||||||
| from ._utils import (is_valid_connection_string, | ||||||||||||||||||||||||
| resolve_store_metadata, | ||||||||||||||||||||||||
| get_store_name_from_connection_string, | ||||||||||||||||||||||||
| get_store_endpoint_from_connection_string, | ||||||||||||||||||||||||
| validate_feature_flag_name, | ||||||||||||||||||||||||
| validate_feature_flag_key) | ||||||||||||||||||||||||
| validate_feature_flag_key, | ||||||||||||||||||||||||
| is_http_endpoint) | ||||||||||||||||||||||||
| from ._models import QueryFields | ||||||||||||||||||||||||
| from ._constants import ImportExportProfiles | ||||||||||||||||||||||||
| from ._featuremodels import FeatureQueryFields | ||||||||||||||||||||||||
|
|
@@ -64,12 +66,31 @@ def validate_connection_string(cmd, namespace): | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def validate_auth_mode(namespace): | ||||||||||||||||||||||||
| auth_mode = namespace.auth_mode | ||||||||||||||||||||||||
| endpoint = getattr(namespace, 'endpoint', None) | ||||||||||||||||||||||||
| connection_string = getattr(namespace, 'connection_string', None) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if auth_mode != "anonymous": | ||||||||||||||||||||||||
| # Disallow HTTP endpoints unless explicitly using anonymous mode. | ||||||||||||||||||||||||
| if endpoint and is_http_endpoint(endpoint): | ||||||||||||||||||||||||
| raise CLIError("HTTP endpoint is only supported when auth mode is 'anonymous'.") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if connection_string: | ||||||||||||||||||||||||
| conn_endpoint = get_store_endpoint_from_connection_string(connection_string) | ||||||||||||||||||||||||
| if is_http_endpoint(conn_endpoint): | ||||||||||||||||||||||||
| raise CLIError("HTTP endpoint is only supported when auth mode is 'anonymous'.") | ||||||||||||||||||||||||
|
Comment on lines
+74
to
+80
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'm not sure if this works with like 83 as I'm not familiar with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I am not sure I understand. Getting the endpoint parameter twice?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't get the same endpoint twice, but we have two code blocks that both check the endpoint, only one is needed, unless it messes with the line mentioned below. |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if auth_mode == "login": | ||||||||||||||||||||||||
| if not namespace.name and not namespace.endpoint: | ||||||||||||||||||||||||
| if not namespace.name and not endpoint: | ||||||||||||||||||||||||
| raise CLIError("App Configuration name or endpoint should be provided if auth mode is 'login'.") | ||||||||||||||||||||||||
| if namespace.connection_string: | ||||||||||||||||||||||||
| if connection_string: | ||||||||||||||||||||||||
| raise CLIError("Auth mode should be 'key' when connection string is provided.") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if auth_mode == "anonymous": | ||||||||||||||||||||||||
| if not endpoint: | ||||||||||||||||||||||||
| raise RequiredArgumentMissingError("App Configuration endpoint should be provided if auth mode is 'anonymous'.") | ||||||||||||||||||||||||
| if connection_string: | ||||||||||||||||||||||||
| raise CLIError("Auth mode 'anonymous' only supports the '--endpoint' argument. Connection string is not supported.") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def validate_import_depth(namespace): | ||||||||||||||||||||||||
| depth = namespace.depth | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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.
Is saying
anonymoususeful here as the simulator is also a requirement. It could mislead someone to thinking our service allows it.Uh oh!
There was an error while loading. Please reload this page.
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.
Maybe we can mention in our help texts anonymous is only used with the app configuration emulator?
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.
Yes, that works.