Skip to content
Merged
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ Processes a single kerberos client-side step using the supplied server challenge
| challenge | <code>string</code> | The response returned after calling `unwrap` |
| [options] | <code>object</code> | Optional settings |
| [options.user] | <code>string</code> | The user to authorize |
| [options.protect] | <code>boolean</code> | Indicates if the wrap should request message confidentiality |
| [callback] | <code>function</code> | |

Perform the client side kerberos wrap step.
Expand Down
1 change: 1 addition & 0 deletions lib/kerberos.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ KerberosClient.prototype.step = defineOperation(KerberosClient.prototype.step, [
* @param {string} challenge The response returned after calling `unwrap`
* @param {object} [options] Optional settings
* @param {string} [options.user] The user to authorize
* @param {string} [options.protect] Indicates if the wrap should request message confidentiality
* @param {function} [callback]
* @return {Promise} returns Promise if no callback passed
*/
Expand Down
7 changes: 7 additions & 0 deletions src/kerberos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ std::string ToStringWithNonStringAsEmpty(Napi::Value value) {
return value.As<String>();
}

int BooleanToIntWithNonIntAsFalse(Napi::Value value) {
if (!value.IsBoolean()) {
throw Error::New(value.Env(), "Expected a boolean value");
}
return value.As<Boolean>().Value() ? 1 : 0;
}

Function KerberosClient::Init(Napi::Env env) {
return
DefineClass(env,
Expand Down
2 changes: 2 additions & 0 deletions src/kerberos.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ void TestMethod(const Napi::CallbackInfo& info);

std::string ToStringWithNonStringAsEmpty(Napi::Value value);

int BooleanToIntWithNonIntAsFalse(Napi::Value value);

}

#endif // KERBEROS_NATIVE_EXTENSION_H
3 changes: 1 addition & 2 deletions src/unix/kerberos_unix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ void KerberosClient::WrapData(const CallbackInfo& info) {
Object options = info[1].ToObject();
Function callback = info[2].As<Function>();
std::string user = ToStringWithNonStringAsEmpty(options["user"]);

int protect = 0; // NOTE: this should be an option
int protect = BooleanToIntWithNonIntAsFalse(options["protect"]);

KerberosWorker::Run(callback, "kerberos:ClientWrap", [=](KerberosWorker::SetOnFinishedHandler onFinished) {
gss_result result = authenticate_gss_client_wrap(
Expand Down
2 changes: 1 addition & 1 deletion src/win32/kerberos_win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void KerberosClient::WrapData(const CallbackInfo& info) {
Object options = info[1].ToObject();
Function callback = info[2].As<Function>();
std::string user = ToStringWithNonStringAsEmpty(options["user"]);
int protect = 0; // NOTE: this should be an option
int protect = BooleanToIntWithNonIntAsFalse(options["protect"]);

if (isStringTooLong(user)) {
throw Error::New(info.Env(), "User name is too long");
Expand Down