diff --git a/CLI/actioner/sonic_cli_authentication.py b/CLI/actioner/sonic_cli_authentication.py index 55c24dc9cb..940c4b8116 100644 --- a/CLI/actioner/sonic_cli_authentication.py +++ b/CLI/actioner/sonic_cli_authentication.py @@ -28,18 +28,7 @@ def invoke_api(func, args): body = None path = None # Set/Get the rules of all IFA table entries. - if func == "get_sonic_client_auth_rest": - path = cc.Path( - "/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default/client_auth" - ) - return api.get(path) - elif func == "get_sonic_client_auth_telemetry": - path = cc.Path( - "/restconf/data/sonic-mgmt-telemetry:sonic-mgmt-telemetry/TELEMETRY/TELEMETRY_LIST=gnmi/client_auth" - ) - return api.get(path) - - elif func == "get_sonic_client_rest": + if func == "get_sonic_client_rest": if len(args) < 1 : path = cc.Path( "/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default") @@ -62,12 +51,12 @@ def invoke_api(func, args): elif args[0] == 'read-timeout': path = cc.Path( "/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default/read_timeout") - elif args[0] == 'security-profile': + elif args[0] == 'authentication': path = cc.Path( - "/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default/security_profile") + "/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default/client_auth") else: path = cc.Path( - "/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default") + "/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default/security_profile") return api.get(path) elif func == "get_sonic_client_telemetry": @@ -87,6 +76,9 @@ def invoke_api(func, args): elif args[0] == 'port': path = cc.Path( "/restconf/data/sonic-mgmt-telemetry:sonic-mgmt-telemetry/TELEMETRY/TELEMETRY_LIST=gnmi/port") + elif args[0] == 'authentication': + path = cc.Path( + "/restconf/data/sonic-mgmt-telemetry:sonic-mgmt-telemetry/TELEMETRY/TELEMETRY_LIST=gnmi/client_auth") else: path = cc.Path( "/restconf/data/sonic-mgmt-telemetry:sonic-mgmt-telemetry/TELEMETRY/TELEMETRY_LIST=gnmi/security_profile") diff --git a/CLI/renderer/templates/show_mgmt_rest_telemetry.j2 b/CLI/renderer/templates/show_mgmt_rest_telemetry.j2 index 547f90dfb3..9c12058867 100644 --- a/CLI/renderer/templates/show_mgmt_rest_telemetry.j2 +++ b/CLI/renderer/templates/show_mgmt_rest_telemetry.j2 @@ -5,6 +5,7 @@ {% set vars = {'req_limit': ""} %} {% set vars = {'read_timeout': ""} %} {% set vars = {'security_profile': ""} %} +{% set vars = {'client_auth': ""} %} {% if json_output -%} {{ ' ' }} @@ -17,6 +18,7 @@ {% if vars.update({'jwt_refresh':900}) %}{% endif %} {% if vars.update({'req_limit':0}) %}{% endif %} {% if vars.update({'read_timeout':30}) %}{% endif %} +{% if vars.update({'client_auth':"password,jwt"}) %}{% endif %} {% if vars.update({'security_profile':"not-set"}) %}{% endif %} {% else %} {% for vals in rest_keys %} @@ -55,6 +57,11 @@ {% else %} {% if vars.update({'security_profile':"not-set"}) %}{% endif %} {% endif %} +{% if "client_auth" in vals %} +{% if vars.update({'client_auth':vals["client_auth"]}) %}{% endif %} +{% else %} +{% if vars.update({'client_auth':"password,jwt"}) %}{% endif %} +{% endif %} {% endfor %} {% endif %} Log level is {{vars.log_level}} @@ -63,6 +70,7 @@ JWT refresh is {{vars.jwt_refresh}} seconds Port is {{vars.port}} Request limit is {{vars.req_limit}} Read timeout is {{vars.read_timeout}} seconds +Client authentication mode is {{vars.client_auth}} Security profile is {{vars.security_profile}} {% endif %} @@ -90,12 +98,13 @@ Security profile is {{json_output["sonic-mgmt-rest:security_profile"]}} {% if "sonic-mgmt-telemetry:TELEMETRY_LIST" in json_output %} {% set telem_keys = json_output["sonic-mgmt-telemetry:TELEMETRY_LIST"] %} -{% if rest_keys|length == 0 %} +{% if telem_keys|length == 0 %} {% if vars.update({'log_level':"not-set"}) %}{% endif %} {% if vars.update({'port':8080}) %}{% endif %} {% if vars.update({'jwt_valid':3600}) %}{% endif %} {% if vars.update({'jwt_refresh':900}) %}{% endif %} {% if vars.update({'security_profile':"not-set"}) %}{% endif %} +{% if vars.update({'client_auth':"password,jwt"}) %}{% endif %} {% else %} {% for vals in telem_keys %} {% if "log_level" in vals %} @@ -123,6 +132,11 @@ Security profile is {{json_output["sonic-mgmt-rest:security_profile"]}} {% else %} {% if vars.update({'security_profile':"not-set"}) %}{% endif %} {% endif %} +{% if "client_auth" in vals %} +{% if vars.update({'client_auth':vals["client_auth"]}) %}{% endif %} +{% else %} +{% if vars.update({'client_auth':"password,jwt"}) %}{% endif %} +{% endif %} {% endfor %} {% endif %} @@ -130,6 +144,7 @@ Log level is {{vars.log_level}} JWT valid is {{vars.jwt_valid}} seconds JWT refresh is {{vars.jwt_refresh}} seconds Port is {{vars.port}} +Client authentication mode is {{vars.client_auth}} Security profile is {{vars.security_profile}} {% endif %}