Skip to content
Permalink
Browse files

feat(kerberos): add getters to check for context completeness

  • Loading branch information
mbroadst committed Jul 2, 2018
1 parent b065707 commit 6a9a01dde33bfb327fa3b46f432b32729e20c04a
Showing with 30 additions and 2 deletions.
  1. +12 −1 src/kerberos_client.cc
  2. +3 −0 src/kerberos_client.h
  3. +12 −1 src/kerberos_server.cc
  4. +3 −0 src/kerberos_server.h
@@ -14,6 +14,7 @@ NAN_MODULE_INIT(KerberosClient::Init) {
Nan::SetAccessor(itpl, Nan::New("username").ToLocalChecked(), KerberosClient::UserNameGetter);
Nan::SetAccessor(itpl, Nan::New("response").ToLocalChecked(), KerberosClient::ResponseGetter);
Nan::SetAccessor(itpl, Nan::New("responseConf").ToLocalChecked(), KerberosClient::ResponseConfGetter);
Nan::SetAccessor(itpl, Nan::New("contextComplete").ToLocalChecked(), KerberosClient::ContextCompleteGetter);

constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked());
Nan::Set(target, Nan::New("KerberosClient").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
@@ -29,7 +30,8 @@ v8::Local<v8::Object> KerberosClient::NewInstance(gss_client_state* state) {
}

KerberosClient::KerberosClient(gss_client_state* state)
: _state(state)
: _state(state),
_contextComplete(false)
{}

KerberosClient::~KerberosClient() {
@@ -62,6 +64,11 @@ NAN_GETTER(KerberosClient::ResponseConfGetter) {
info.GetReturnValue().Set(Nan::New(client->_state->responseConf));
}

NAN_GETTER(KerberosClient::ContextCompleteGetter) {
KerberosClient* client = Nan::ObjectWrap::Unwrap<KerberosClient>(info.This());
info.GetReturnValue().Set(Nan::New(client->_contextComplete));
}

class ClientStepWorker : public Nan::AsyncWorker {
public:
ClientStepWorker(KerberosClient* client, std::string challenge, Nan::Callback *callback)
@@ -77,6 +84,10 @@ class ClientStepWorker : public Nan::AsyncWorker {
SetErrorMessage(result->message);
return;
}

if (result->code == AUTH_GSS_COMPLETE) {
_client->_contextComplete = true;
}
}

private:
@@ -17,16 +17,19 @@ class KerberosClient : public Nan::ObjectWrap {
static NAN_GETTER(UserNameGetter);
static NAN_GETTER(ResponseGetter);
static NAN_GETTER(ResponseConfGetter);
static NAN_GETTER(ContextCompleteGetter);

static NAN_METHOD(Step);
static NAN_METHOD(UnwrapData);
static NAN_METHOD(WrapData);

private:
friend class ClientStepWorker;
explicit KerberosClient(gss_client_state* client_state);
~KerberosClient();

gss_client_state* _state;
bool _contextComplete;
};

#endif
@@ -12,6 +12,7 @@ NAN_MODULE_INIT(KerberosServer::Init) {
Nan::SetAccessor(itpl, Nan::New("username").ToLocalChecked(), KerberosServer::UserNameGetter);
Nan::SetAccessor(itpl, Nan::New("response").ToLocalChecked(), KerberosServer::ResponseGetter);
Nan::SetAccessor(itpl, Nan::New("targetName").ToLocalChecked(), KerberosServer::TargetNameGetter);
Nan::SetAccessor(itpl, Nan::New("contextComplete").ToLocalChecked(), KerberosServer::ContextCompleteGetter);

constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked());
Nan::Set(target, Nan::New("KerberosServer").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
@@ -27,7 +28,8 @@ v8::Local<v8::Object> KerberosServer::NewInstance(gss_server_state* state) {
}

KerberosServer::KerberosServer(gss_server_state* state)
: _state(state)
: _state(state),
_contextComplete(false)
{}

KerberosServer::~KerberosServer() {
@@ -62,6 +64,11 @@ NAN_GETTER(KerberosServer::TargetNameGetter) {
info.GetReturnValue().Set(Nan::New(server->_state->targetname).ToLocalChecked());
}

NAN_GETTER(KerberosServer::ContextCompleteGetter) {
KerberosServer* server = Nan::ObjectWrap::Unwrap<KerberosServer>(info.This());
info.GetReturnValue().Set(Nan::New(server->_contextComplete));
}

class ServerStepWorker : public Nan::AsyncWorker {
public:
ServerStepWorker(KerberosServer* server, std::string challenge, Nan::Callback *callback)
@@ -77,6 +84,10 @@ class ServerStepWorker : public Nan::AsyncWorker {
SetErrorMessage(result->message);
return;
}

if (result->code == AUTH_GSS_COMPLETE) {
_server->_contextComplete = true;
}
}

private:
@@ -17,14 +17,17 @@ class KerberosServer : public Nan::ObjectWrap {
static NAN_GETTER(UserNameGetter);
static NAN_GETTER(ResponseGetter);
static NAN_GETTER(TargetNameGetter);
static NAN_GETTER(ContextCompleteGetter);

static NAN_METHOD(Step);

private:
friend class ServerStepWorker;
explicit KerberosServer(gss_server_state* server_state);
~KerberosServer();

gss_server_state* _state;
bool _contextComplete;
};

#endif

0 comments on commit 6a9a01d

Please sign in to comment.
You can’t perform that action at this time.