Skip to content

Commit

Permalink
add windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierrotws committed Jan 30, 2015
1 parent a01b59b commit cd7fcb4
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 18 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
43 changes: 43 additions & 0 deletions _binding32.gyp
Original file line number Diff line number Diff line change
@@ -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"]
}
]
]
}
]
}
14 changes: 13 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}
],
[
Expand Down
7 changes: 3 additions & 4 deletions src/krb5.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "krb5.h"
#include <sys/stat.h>

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*
Expand Down Expand Up @@ -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(){
Expand All @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 1 addition & 4 deletions src/krb5.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
//local libs
#include "base64.h"


#define NO_ERROR 0

#ifdef NODEGYP
using namespace v8;

Expand All @@ -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();

Expand Down

0 comments on commit cd7fcb4

Please sign in to comment.