Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable custom port other than 80 and 443 #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
test/
yarn.lock

npm-debug.log
npm-debug.log
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ function CASAuthentication(options) {

this.cas_url = options.cas_url;
var parsed_cas_url = url.parse(this.cas_url);

this.request_client = parsed_cas_url.protocol === 'http:' ? http : https;
this.cas_host = parsed_cas_url.hostname;
this.cas_port = parsed_cas_url.protocol === 'http:' ? 80 : 443;
this.cas_port = parsed_cas_url.port || (parsed_cas_url.protocol === 'http:' ? 80 : 443);
this.cas_path = parsed_cas_url.pathname;

this.service_url = options.service_url;
Expand Down Expand Up @@ -335,6 +336,10 @@ CASAuthentication.prototype._handleTicket = function(req, res, next) {
};
}

if (this.request_client === https && process.env.NODE_TLS_REJECT_UNAUTHORIZED != 0) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
}

var request = this.request_client.request(requestOptions, function(response) {
response.setEncoding( 'utf8' );
var body = '';
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"xml2js": "^0.4.8"
},
"devDependencies": {
"express": "^4.12.3",
"express-session": "^1.11.1"
"express": "^4.16.2",
"express-session": "^1.15.6"
}
}