diff options
| author | Glenn Smith <glenn@vector35.com> | 2021-12-08 18:01:50 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2021-12-08 18:55:33 -0500 |
| commit | 273b30abc8782767d4d94938dcda61b87e8efc83 (patch) | |
| tree | 90bc549a435aad9d87f0676299d6f02c236ff5ff | |
| parent | 645e0c51e6293874acda429dc5e278b185704d9b (diff) | |
[Enterprise] "Remember me" option in api
| -rw-r--r-- | binaryninjacore.h | 4 | ||||
| -rw-r--r-- | python/__init__.py | 2 | ||||
| -rw-r--r-- | python/enterprise.py | 10 |
3 files changed, 9 insertions, 7 deletions
diff --git a/binaryninjacore.h b/binaryninjacore.h index e422ad77..cf1f09f1 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -2685,8 +2685,8 @@ extern "C" BINARYNINJACOREAPI bool BNIsUIEnabled(void); BINARYNINJACOREAPI void BNSetLicense(const char* licenseData); - BINARYNINJACOREAPI bool BNAuthenticateEnterpriseServerWithCredentials(const char* username, const char* password); - BINARYNINJACOREAPI bool BNAuthenticateEnterpriseServerWithMethod(const char* method); + BINARYNINJACOREAPI bool BNAuthenticateEnterpriseServerWithCredentials(const char* username, const char* password, bool remember); + BINARYNINJACOREAPI bool BNAuthenticateEnterpriseServerWithMethod(const char* method, bool remember); BINARYNINJACOREAPI size_t BNGetEnterpriseServerAuthenticationMethods(char*** methods, char*** names); BINARYNINJACOREAPI bool BNDeauthenticateEnterpriseServer(void); BINARYNINJACOREAPI void BNCancelEnterpriseServerAuthentication(void); diff --git a/python/__init__.py b/python/__init__.py index 1cf00773..12cb7033 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -129,7 +129,7 @@ def _init_plugins(): if not core_ui_enabled() and core.BNGetProduct() == "Binary Ninja Enterprise Client": # Enterprise client needs to checkout a license reservation or else BNInitPlugins will fail - if not core.BNAuthenticateEnterpriseServerWithMethod("Keychain") and (not core.BNIsLicenseValidated() or not enterprise.is_license_still_activated()): + if not enterprise.authenticate_with_method("Keychain") and (not core.BNIsLicenseValidated() or not enterprise.is_license_still_activated()): raise RuntimeError( "To use Binary Ninja Enterprise from a headless python script, you must check out a license first.\n" "You can either check out a license for an extended time with the UI, or use the binaryninja.enterprise module.") diff --git a/python/enterprise.py b/python/enterprise.py index 5ea57f0c..b94fd7ca 100644 --- a/python/enterprise.py +++ b/python/enterprise.py @@ -25,24 +25,26 @@ def is_connected() -> bool: return core.BNIsEnterpriseServerConnected() -def authenticate_with_credentials(username: str, password: str): +def authenticate_with_credentials(username: str, password: str, remember: bool = True): """ Authenticate to the Enterprise Server with username/password credentials. :param str username: Username to use. :param str password: Password to use. + :param bool remember: Remember token in keychain """ - if not core.BNAuthenticateEnterpriseServerWithCredentials(username, password): + if not core.BNAuthenticateEnterpriseServerWithCredentials(username, password, remember): raise RuntimeError(last_error()) -def authenticate_with_method(method: str): +def authenticate_with_method(method: str, remember: bool = True): """ Authenticate to the Enterprise Server with a non-password method. Note that many of these will open a URL for a browser-based login prompt, which may not be usable on headless installations. See :func:`authentication_methods` for a list of accepted methods. :param str method: Name of method to use. + :param bool remember: Remember token in keychain """ - if not core.BNAuthenticateEnterpriseServerWithMethod(method): + if not core.BNAuthenticateEnterpriseServerWithMethod(method, remember): raise RuntimeError(last_error()) |
