diff --git a/scripts/quickstart_tooling_dpg/dev_requirements.txt b/scripts/quickstart_tooling_dpg/dev_requirements.txt index 1c579e7d0639..58bc30385a32 100644 --- a/scripts/quickstart_tooling_dpg/dev_requirements.txt +++ b/scripts/quickstart_tooling_dpg/dev_requirements.txt @@ -1 +1 @@ -jinja2 \ No newline at end of file +jinja2==3.1.2 \ No newline at end of file diff --git a/scripts/quickstart_tooling_dpg/main.py b/scripts/quickstart_tooling_dpg/main.py index 97cc1d81f5d6..cdb0e3b3f09b 100644 --- a/scripts/quickstart_tooling_dpg/main.py +++ b/scripts/quickstart_tooling_dpg/main.py @@ -5,7 +5,7 @@ from jinja2 import Environment, FileSystemLoader from subprocess import check_call import time -from typing import Any +from typing import Any, Dict _LOGGER = logging.getLogger(__name__) @@ -106,6 +106,11 @@ def build_package(**kwargs) -> None: _LOGGER.info("Build complete: %s", package_name) +def validate_params(**kwargs): + if not kwargs.get("security_scope") and not kwargs.get("security_header_name"): + raise Exception('At least one of "security-scope" and "security-header-name" is needed') + + def main(**kwargs): build_package(**kwargs) @@ -132,8 +137,14 @@ def main(**kwargs): parser.add_argument( "--security-scope", "-c", dest="security_scope", - required=True, - help="Each service for data plan should have specific scopes", + required=False, + help="If authentication is AADToken, this param is necessary", + ) + parser.add_argument( + "--security-header-name", + dest="security_header_name", + required=False, + help="If authentication is api key, this param is necessary", ) parser.add_argument( "--package-name", "-p", @@ -160,4 +171,5 @@ def main(**kwargs): main_logger.setLevel(logging.INFO) parameters = vars(args) + validate_params(**parameters) main(**parameters) diff --git a/scripts/quickstart_tooling_dpg/template/swagger_README.md b/scripts/quickstart_tooling_dpg/template/swagger_README.md index 184ca45e76da..acea17144992 100644 --- a/scripts/quickstart_tooling_dpg/template/swagger_README.md +++ b/scripts/quickstart_tooling_dpg/template/swagger_README.md @@ -11,6 +11,11 @@ no-namespace-folders: true title: {{ client_name }} version-tolerant: true package-version: 1.0.0b1 +{%- if security_scope %} security: AADToken security-scopes: {{ security_scope }} +{%- elif security_header_name %} +security: AzureKey +security-header-name: {{ security_header_name }} +{%- endif %} ```