Skip to content

Commit 6224d67

Browse files
authored
[yang] Restrict AAA authorization with TACPLUS passkey (sonic-net#18155)
### Why I did it Command cannot be executed when tacacs+ in AAA authorization is set and passkey in TACPLUs is not set. There should be such restriction in YANG model definition. ##### Work item tracking - Microsoft ADO **(number only)**: 26898399 #### How I did it Add restirction #### How to verify it unit test
1 parent 4783a6c commit 6224d67

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
"AAA_AUTHORIZATION_TEST": {
1919
"desc": "Configure an authorization type in AAA table."
2020
},
21+
"AAA_AUTHORIZATION_TEST_TACACS_WITHOUT_TACPLUS": {
22+
"desc": "Configure tacacs in authorization type in AAA table without TACPLUS table.",
23+
"eStr": ["Authorization with 'tacacs+' is not allowed when passkey not exists."]
24+
},
2125
"AAA_ACCOUNTING_TEST": {
2226
"desc": "Configure an accounting type in AAA table."
2327
}

src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json

+19
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,25 @@
4646
},
4747

4848
"AAA_AUTHORIZATION_TEST": {
49+
"sonic-system-aaa:sonic-system-aaa": {
50+
"sonic-system-aaa:AAA": {
51+
"AAA_LIST": [{
52+
"type": "authorization",
53+
"login": "tacacs+"
54+
}]
55+
}
56+
},
57+
"sonic-system-tacacs:sonic-system-tacacs": {
58+
"sonic-system-tacacs:TACPLUS": {
59+
"global": {
60+
"timeout": 5,
61+
"passkey": "aabb"
62+
}
63+
}
64+
}
65+
},
66+
67+
"AAA_AUTHORIZATION_TEST_TACACS_WITHOUT_TACPLUS": {
4968
"sonic-system-aaa:sonic-system-aaa": {
5069
"sonic-system-aaa:AAA": {
5170
"AAA_LIST": [{

src/sonic-yang-models/yang-models/sonic-system-aaa.yang

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ module sonic-system-aaa {
77
prefix stypes;
88
}
99

10+
import sonic-system-tacacs{
11+
prefix tacacs;
12+
}
13+
1014
revision 2021-10-12 {
1115
description "Add AAA authorization/accounting support.";
1216
}
@@ -39,6 +43,10 @@ module sonic-system-aaa {
3943
default "local";
4044
}
4145

46+
must 'not(./type = "authorization" and contains(./login, "tacacs+") and not(/tacacs:sonic-system-tacacs/tacacs:TACPLUS/tacacs:global/tacacs:passkey))' {
47+
error-message "Authorization with 'tacacs+' is not allowed when passkey not exists.";
48+
}
49+
4250
leaf failthrough {
4351
type stypes:boolean_type;
4452
description "When set to true, authentication is attempted on next configured server/local in the list upon failure.";

0 commit comments

Comments
 (0)