koajs / koajs/userauth

有循环重定向的可能

Open
#14 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
139
Forks
17
PR merge metrics
No merged PRs in 30d

Description

```
if (!this.session) {
debug('this.session not exists');
// ignore not match path
if (!loginRequired) {
debug('not match needLogin path, %j', this.path);
return yield next;
}
debug('relogin again');
return yield loginHandler.call(this, next);
}

// get login path
if (this.path === options.loginPath) {
debug('match login path');
return yield loginHandler.call(this, next);
}
```

场景:

loginPath=/login
loginHost=demo.xxx.com
浏览器中输入demo.xxx.com/login (带有部分cookie),这是就能跳过第一个判断if (!this.session)
而 if (this.path === options.loginPath) 符合条件!
最终就会执行到loginHandler 的 redirect(this, loginURL);
@fengmk2

Contributor guide

Open the contributing guide

Research direction

Start by tracing the middleware branch shown in the issue, focusing on this.session, options.loginPath, loginHandler, and redirect. Reproduce the /login request with partial cookies and verify that the login path no longer redirects back to itself while normal unauthenticated redirects still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.