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

fix: 使用originalUrl代替url,因为express会重写url #23

Open
wants to merge 3 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: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
***due to origin owner doesnot update origin repository, i fixed some bug in this project***
***因为源项目作者不再维护,但是我还要使用,所以开了这个项目进行维护,修复一些bug***

# Express CAS Authentication

This is a CAS authentication library designed to be used with an Express server.
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ CASAuthentication.prototype._login = function(req, res, next) {

// Save the return URL in the session. If an explicit return URL is set as a
// query parameter, use that. Otherwise, just use the URL from the request.
req.session.cas_return_to = req.query.returnTo || url.parse(req.url).path;
req.session.cas_return_to = req.query.returnTo || url.parse(req.originalUrl).path;

// Set up the query parameters.
var query = {
service: this.service_url + url.parse(req.url).pathname,
service: this.service_url + url.parse(req.originalUrl).pathname,
renew: this.renew
};

Expand Down Expand Up @@ -300,7 +300,7 @@ CASAuthentication.prototype._handleTicket = function(req, res, next) {
requestOptions.path = url.format({
pathname: this.cas_path + this._validateUri,
query: {
service: this.service_url + url.parse(req.url).pathname,
service: this.service_url + url.parse(req.originalUrl).pathname,
ticket: req.query.ticket
}
});
Expand All @@ -325,7 +325,7 @@ CASAuthentication.prototype._handleTicket = function(req, res, next) {
requestOptions.path = url.format({
pathname: this.cas_path + this._validateUri,
query : {
TARGET : this.service_url + url.parse(req.url).pathname,
TARGET : this.service_url + url.parse(req.originalUrl).pathname,
ticket: ''
}
});
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cas-authentication",
"version": "0.0.8",
"name": "cas-authentication-by-alt",
"version": "0.0.9",
"description": "A CAS authentication library designed to be used as middleware for an Express server.",
"keywords": [
"cas",
Expand Down