diff options
| author | Glenn Smith <glenn@vector35.com> | 2026-03-17 16:15:41 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2026-04-20 12:37:02 -0400 |
| commit | 68f04aca3f4e04c1ec2c3b5d54c04ff05e9b0c58 (patch) | |
| tree | 55f9128c8bcf02e1cf43c926ebd1fd4236b8aea1 /enterprise.cpp | |
| parent | bfd306437f34ebc4d4170c5fb8170261585f6038 (diff) | |
Enterprise: Add AuthenticateWithToken api
For when you have a token and want to auth with it directly
Diffstat (limited to 'enterprise.cpp')
| -rw-r--r-- | enterprise.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/enterprise.cpp b/enterprise.cpp index d2f9ccad..ba3b5db7 100644 --- a/enterprise.cpp +++ b/enterprise.cpp @@ -36,6 +36,12 @@ bool BinaryNinja::Enterprise::Initialize() } +bool BinaryNinja::Enterprise::AuthenticateWithToken(const std::string& token, bool remember) +{ + return BNAuthenticateEnterpriseServerWithToken(token.c_str(), remember); +} + + bool BinaryNinja::Enterprise::AuthenticateWithCredentials(const std::string& username, const std::string& password, bool remember) { return BNAuthenticateEnterpriseServerWithCredentials(username.c_str(), password.c_str(), remember); @@ -282,10 +288,19 @@ BinaryNinja::Enterprise::LicenseCheckout::LicenseCheckout(int64_t duration): m_a } if (!gotAuth) { + char* token = getenv("BN_ENTERPRISE_TOKEN"); + if (token) + { + gotAuth = AuthenticateWithToken(token, true); + } + } + if (!gotAuth) + { throw EnterpriseException( "Could not checkout a license: Not authenticated. Try one of the following: \n" " - Log in and check out a license for an extended time\n" " - Set BN_ENTERPRISE_USERNAME and BN_ENTERPRISE_PASSWORD environment variables\n" + " - Set BN_ENTERPRISE_TOKEN environment variable\n" " - Use BinaryNinja::Enterprise::AuthenticateWithCredentials or AuthenticateWithMethod in your code" ); } |
