Document requirement for cookie path when using paths other than /login
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 45/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
調査の方向性
まず、この issue の cookie 戦略に関するドキュメントと設定例を確認してください。/login 以外のログインパスを使用する場合は cookie パスを / に設定する必要があることを、/foo/login の例とともに文書化してください。関連するドキュメントで要件が明確になっていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Context
- node version: 14.15.4
- module version: 11.0.2
What are you trying to achieve or the steps to reproduce ?
We wasted several hours trying to configure our login page to be something other than /login, in the example below we tried using /foo.login. After asking in the Hapi slack channel, it was pointed out to us that if you do not assign the cookie a path, it defaults to null and only works with the path /login and therefore breaks the code if you do not specify it as / for a different path. It would be appreciated if the documentation was updated with this an example or highlight that the path must be noted if you wish to using anything other than the default.
const Bcrypt = require('bcrypt');
// create a server with a host and port
const server = new Hapi.Server({
host: 'localhost',
port: 3000
})
const users = [
{
username: 'john',
password: '$2a$10$iqJSHD.BGr0E2IxQwYgJmeP3NvhPrXAeLSaGCj6IR/XU5QtjVu5Tm', // 'secret'
name: 'John Doe',
id: '2133d32a'
}
];
async function start () {
await server.register(require('@hapi/cookie'));
server.auth.strategy('session', 'cookie', {
cookie: {
name: 'sid-example',
password: '!wsYhFA*C2U6nz=Bu^%A@^F#SF3&kSR6',
isSecure: false,
path: '/'
},
redirectTo: '/foo/login',
validateFunc: async (request, session) => {
const account = await users.find(
(user) => (user.id === session.id)
);
if (!account) {
return { valid: false };
}
return { valid: true, credentials: account };
}
});
server.auth.default('session');
server.route([
{
method: 'GET',
path: '/',
handler: function (request, h) {
return 'Welcome to the restricted home page!';
}
},
{
method: 'GET',
path: '/foo/login',
handler: function (request, h) {
return ` <html>
<head>
<title>Login page</title>
</head>
<body>
<h3>Please Log In</h3>
<form method="post" action="/foo/login">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br/>
<input type="submit" value="Login"></form>
</body>
</html>`;
},
options: {
auth: false
}
},
{
method: 'POST',
path: '/foo/login',
handler: async (request, h) => {
const { username, password } = request.payload;
const account = users.find(
(user) => user.username === username
);
if (!account || !(await Bcrypt.compare(password, account.password))) {
return h.view('/foo/login');
}
request.cookieAuth.set({ id: account.id });
return h.redirect('/');
},
options: {
auth: {
mode: 'try'
}
}
}
]);
// start your server
try {
await server.start()
} catch (err) {
console.error(err)
process.exit(1)
}
console.log('Server running at: ', server.info.uri)
}
start()
- 主要言語
- JavaScript
- スター
- 229
- フォーク
- 99
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hapijs/cookie のほかの issue
-
support
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
ttl和keepAlive功能存在bugオープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
feature
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
support
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
support
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
obsidianmd/obsidian-help#1169 ·
メンテナーはふだん 2 日以内に返信
-
[docs] RELEASE.md: wrong branch name, no check that the prepare PR merged with the right subject, manual publish step対応中かも @albertteoh が今日担当しました。 オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
jaegertracing/jaeger-ui#4739 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
keepassxreboot/keepassxc-browser#3159 · コメント 1 件 ·
-
Add: ESP 2 RSオープンapproved check:passed feeds:add
難易度 1/5 1時間未満 初心者へのやさしさ 67/100