Adding logout function and context manager into Authentication class#180
Open
Jypear wants to merge 3 commits intoCiscoDevNet:masterfrom
Open
Adding logout function and context manager into Authentication class#180Jypear wants to merge 3 commits intoCiscoDevNet:masterfrom
Jypear wants to merge 3 commits intoCiscoDevNet:masterfrom
Conversation
…ext manager - Created logout function which sends a request the the logout endpoint - Created __enter__ and __exit__ methods which allow for use of a context manager
Author
|
It looks like theres a flag with the use of randint on the logout when a random number needs to be generated on the logout. https://developer.cisco.com/docs/sdwan/#!authentication/how-to-authenticate If this will be a problem I can find an alternative solution if needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Hi,
I hope the maintainers accept PRs for this repository still. I recently received a suggestion from Cisco TAC that an issue could potentially be being caused by an API account not terminating its sessions properly. This API account is heavily used and with sessions not being terminated there is a high amount of active authenticated sessions waiting for the standard 30 minute time out. We use this SDK quite heavily in some services and I noticed there is currently no built in way to trigger a logout, so I'm submitting a PR for one.
The logout function is relatively similar to the login function with some subtle differences:
This function can be called directly if the user initiated the class and called login after the fact. However if the user followed the example and called login directly without storing the initiated class the user can pass an optional "session" argument to specify the session they wish to terminate (they would not need to pass credentials on the logout call).
This correctly terminates the session on the vManage.
The authentication class also includes a context manager to control the session within the context to allow for properly closing the session on an error.
This then allows the user to control their connection with a with statement instead:
Hopefully the PR is okay, if theres anything that needs changing or their are suggested improvements just let me know.
Cheers