diff --git a/README.md b/README.md index dc566d9..3a94fb3 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,27 @@ Please see the first example in the samples directory for a concrete use case. # Installation -The installation assumes that you have mit-kerberos installed on your computer. +The installation assumes that you have mit-kerberos installed on your computer. If you are on Linux, just do +```bash +npm install +``` +If you are on Windows or Mac OS, please read the corresponding section + +## Windows + +To compile this library in windows, you need a complete visual studio compile chain, please refer to this [webpage][visual studio]. +If you have a 32 bit OS, please delete binding.gyp and rename _binding32.gyp before install. -IF YOU USE MAC OS X, PLEASE MANUALLY COMPILE MIT KERBEROS, AND MODIFY BINDING.GYP AS EXPLAINED BELOW. +## Mac OS X If you encounter troubles with your kerberos version, please compile kerberos using the following instructions. -Your default include directories must contain: +Your include path must contain: krb5.h * *gssapi.h* * *gssapi/gssapi_krb5.h* -Your default library directories must contain: +Your library path must contain: * *krb5* library * *gssapi_krb5* library @@ -37,8 +46,8 @@ make sudo make install ``` -If kerberos is not installed in one of theses directories (if you have manually -compiled kerberos in a specific directory for example), please merge the +If kerberos is not installed in a directory not included in include and/or library path (if you have manually +compiled kerberos in a specific directory for example), please modify the binding.gyp present in the package root folder with the following properties: ```js @@ -85,6 +94,4 @@ for more example, see the samples directory [MIT Kerberos]: http://web.mit.edu/kerberos/ [SPNEGO]: http://en.wikipedia.org/wiki/SPNEGO [MIT Kerberos Dist]: http://web.mit.edu/kerberos/dist/ - - - +[visual studio]:https://github.com/TooTallNate/node-gyp/wiki/Visual-Studio-2010-Setup \ No newline at end of file diff --git a/_binding32.gyp b/_binding32.gyp new file mode 100644 index 0000000..98db769 --- /dev/null +++ b/_binding32.gyp @@ -0,0 +1,43 @@ +{ + "targets": [ + { + "target_name": "krb5", + "cflags!": [ "-fno-exceptions" ], + "cflags_cc!": [ "-fno-exceptions" ], + "defines" : ["NODEGYP"], + "sources": ["src/krb5.cc","src/base64.cc"], + "conditions": [ + [ + "OS=='mac'", + { + "libraries": ["-lkrb5", "-lgssapi_krb5"] + } + ], + [ + "OS=='win'", + { + "variables": { + "KRB_PATH": "/Program Files/MIT/Kerberos" + }, + "include_dirs": ["<(KRB_PATH)/include","<(KRB_PATH)/include/gssapi","src"], + "msvs_settings": { + "VCCLCompilerTool": { + "AdditionalOptions": [ "/MP /EHsc" ] + }, + 'VCLinkerTool': { + 'AdditionalLibraryDirectories': ['/Program Files/Microsoft SDKs/Windows/v7.1/Lib', '<(KRB_PATH)/lib/i386/'] + } + }, + "libraries": ["-lkrb5_32.lib","-lgssapi32.lib"], + } + ], + [ + "OS=='linux'", + { + "libraries": ["-lkrb5", "-lgssapi_krb5"] + } + ] + ] + } + ] +} \ No newline at end of file diff --git a/binding.gyp b/binding.gyp index eff2c28..a957b5b 100644 --- a/binding.gyp +++ b/binding.gyp @@ -16,7 +16,19 @@ [ "OS=='win'", { - "libraries": ["-lkrb5.lib", "-lgssapi_krb5.lib"] + "variables": { + "KRB_PATH": "/Program Files/MIT/Kerberos" + }, + "include_dirs": ["<(KRB_PATH)/include","<(KRB_PATH)/include/gssapi","src"], + "msvs_settings": { + "VCCLCompilerTool": { + "AdditionalOptions": [ "/MP /EHsc" ] + }, + 'VCLinkerTool': { + 'AdditionalLibraryDirectories': ['/Program Files/Microsoft SDKs/Windows/v7.1/Lib/x64', '<(KRB_PATH)/lib/amd64/'] + } + }, + "libraries": ["-lkrb5_64.lib","-lgssapi64.lib"], } ], [ diff --git a/src/krb5.cc b/src/krb5.cc index 9467bc2..d351157 100644 --- a/src/krb5.cc +++ b/src/krb5.cc @@ -1,5 +1,4 @@ #include "krb5.h" -#include static gss_OID_desc _gss_mech_spnego = {6, (void*)"\x2b\x06\x01\x05\x05\x02"}; //Spnego OID: 1.3.6.1.5.5.2 static const gss_OID GSS_MECH_SPNEGO= &_gss_mech_spnego; //gss_OID == gss_OID_desc* @@ -79,7 +78,7 @@ krb5_error_code Krb5::cleanup(int level) { } Krb5::~Krb5() { - this->cleanup(NO_ERROR); + this->cleanup(0); } const char* Krb5::get_error_message(){ @@ -94,7 +93,7 @@ krb5_error_code Krb5::get_credentials_by_keytab(const char* keytabName) { int len = strlen(keytabName); if(len) { strcpy(kt,"FILE:"); - strcat(kt,realpath(keytabName,NULL)); + strcat(kt,keytabName); this->err = krb5_kt_resolve(this->context, kt, &keytab); } else { @@ -128,7 +127,7 @@ krb5_error_code Krb5::get_credentials_by_keytab(const char* keytabName) { } -krb5_error_code Krb5::get_credentials_by_password(const char* password) { +krb5_error_code Krb5::get_credentials_by_password(char* password) { if(!this->err){ this->err = krb5_get_init_creds_password(this->context,this->cred,this->client_principal,password, NULL, NULL, 0, NULL, NULL); if(this->err) { diff --git a/src/krb5.h b/src/krb5.h index 74c4f9c..8d137ec 100644 --- a/src/krb5.h +++ b/src/krb5.h @@ -20,9 +20,6 @@ //local libs #include "base64.h" - -#define NO_ERROR 0 - #ifdef NODEGYP using namespace v8; @@ -48,7 +45,7 @@ class Krb5 { krb5_error_code destroy(const char* name=NULL); virtual ~Krb5(); krb5_error_code get_credentials_by_keytab(const char* keytab=NULL); - krb5_error_code get_credentials_by_password(const char* principal); + krb5_error_code get_credentials_by_password(char* password); OM_uint32 generate_spnego_token(const char* server); const char* get_error_message();