-
Notifications
You must be signed in to change notification settings - Fork 753
Integrated Security Cipher for TACPLUS passkey encryption #3936
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: master
Are you sure you want to change the base?
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@anders-nexthop @qiluo-msft Please review the updated integration of Security Cipher module with TACPLUS feature. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@anders-nexthop please help in adding the reviewers. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
12a512c to
df0cbec
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
anders-nexthop
left a comment
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.
Needs some work still, but seems much cleaner after your changes to the underlying key_encrypt system.
| VALID_CHARS_MSG = "Valid chars are ASCII printable except SPACE, '#', and ','" | ||
| TACACS_PASSKEY_MAX_LEN = 65 | ||
|
|
||
| secure_cipher = master_key_mgr(security_cipher_clbk_lookup) |
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.
where is security_cipher_cblk_lookup defined?
| def login(db, auth_protocol): | ||
| """Switch login authentication [ {ldap, radius, tacacs+, local} | default ]""" | ||
| if len(auth_protocol) is 0: | ||
| if len(auth_protocol) == 0: |
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.
seems unrelated?
| add_table_kv('TACPLUS', 'global', 'passkey', b64_encoded) | ||
| else: | ||
| # Deregister feature with Security Cipher module | ||
| secure_cipher.deregister("TACPLUS", rotate_tacplus_key) |
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.
why would we deregister if the encryption failed? also, where is rotate_tacplus_key defined?
| secure_cipher.set_feature_password("TACPLUS", passwd) | ||
| else: | ||
| # Check if password rotation is enabled | ||
| if rotate: |
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.
nit: could be else-if with else statement above
| if rotate: | ||
| passwd = getpass.getpass() | ||
| # Rotate password for TACPLUS feature and re-encrypt the secret | ||
| secure_cipher.rotate_feature_passwd("TACPLUS", passwd) |
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 we need to encrypt the secret here as well? maybe this shouldn't return?
| """Specify TACACS+ server global passkey <STRING>""" | ||
| if ctx.obj == 'default': | ||
| del_table_key(db, 'TACPLUS', 'global', 'passkey') | ||
| elif secret: |
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.
in secret is not defined? then what? is the idea that an empty secret disables the passkey entirely? what happens if we pass an empty secret and --encrypt?
| else: | ||
| click.echo('Argument "secret" is required') | ||
| if secure_cipher.is_key_encrypt_enabled("TACPLUS", "global"): | ||
| secure_cipher.deregister("TACPLUS", "TACPLUS|global") |
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.
so if we run without --encrypt, we will remove the associated key encryption password and set key_encrypt to false, since the user is no longer wanting encryption. this seems correct.
What about the --rotate option though? if a user passes --rotate without --encrypt, what then? we should at least throw an error in that case, rather than removing the encryption.
| @click.option('-m', '--use-mgmt-vrf', help="Management vrf, default is no vrf", is_flag=True) | ||
| @clicommon.pass_db | ||
| def add(db, address, timeout, key, auth_type, port, pri, use_mgmt_vrf): | ||
| def add(address, timeout, key, encrypted_key, rotate, auth_type, port, pri, use_mgmt_vrf, encrypt): |
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.
I don't see --encrypt as an arg?
| raise click.UsageError("You must provide either --key or --encrypted_key") | ||
|
|
||
| if encrypted_key is not None: | ||
| try: |
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.
this is almost the same as the block above, lets refactor them to re-use the logic
| if key is not None: | ||
| data['passkey'] = key | ||
|
|
||
| if key and encrypted_key: |
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.
would it make more sense to keep just --key and have an --encrypt argument, instead of --encrypted_key? --encrypted_key sounds like you are passing in a key that is already encrypted, which is not true; you are passing in a plaintext key that you WANT to be encrypted.
What I did
Made use of Security Cipher module to encrypt the TACPLUS passkey.
How I did it
Implemented the feature by following HLD
How to verify it
Unit test logs:
Note: This PR is created by closing the old PR due to several merge conflicts.