hapi js social login session management
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- javascript, node.js
調査の方向性
まず認証設定を読み、/auth/google と /logout で使用されている戦略を比較します。示されている Node 12.16.1、Hapi 11.0.2、Bell、Cookie の構成で 401 を再現し、その後、確立された Cookie セッションが受け入れられない理由を追跡します。必要な設定変更を文書化できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Support plan
- is this issue currently blocking your project? (yes):
- is this issue affecting a production system? (no):
Context
- node version: 12.16.1
- module version: 11.0.2
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...): hapi and bell
- any other relevant information:
How can we help?
I am using hapi js along with bell and cookie for allowing users to log on to the application using google credentials.
I've defined two strategies. one with bell-google and another with cookie-session. The intention is, once the user logged in, the session needs to be maintained.
I am able to successfully redirect the user to google login page and after successful authentication, able to fetch the user profile.
However, when I access logout API, I am getting the following error.
{"statusCode":401,"error":"Unauthorized","message":"Missing authentication"}
Here is my code. Any guidance to resolve this issue will be highly helpful.
"use strict";
const Bell = require("@hapi/bell");
const Hapi = require("@hapi/hapi");
const Cookie = require("@hapi/cookie");
const init = async () => {
const server = Hapi.server({
port: 3000,
host: "localhost",
routes: { cors: { origin: ["*"] } },
});
let plugins = [
{
plugin: Bell,
},
{
plugin: Cookie,
},
];
await server.register(plugins);
server.auth.strategy("session", "cookie", {
cookie: {
name: "sid-example",
// Don't forget to change it to your own secret password!
password: "this-is-a-32-character-password",
// For working via HTTP in localhost
isSecure: false,
},
});
server.auth.strategy("google", "bell", {
provider: "google",
password: "this-is-a-32-character-password",
isSecure: false,
clientId: "google-client-id",
clientSecret: "google-client-secret",
});
server.auth.default("google");
server.route({
method: "GET",
path: "/auth/google",
options: {
auth: {
strategy: "google",
mode: "required",
},
handler: function (request, h) {
if (!request.auth.isAuthenticated) {
return "Authentication failed due to: " + request.auth.error.message;
} else {
let creds = request.auth.credentials;
request.cookieAuth.set({
token: creds.token,
email: creds.profile.email,
});
}
return (
"<pre> response = " +
JSON.stringify(request.auth.credentials, null, 4) +
"</pre>"
);
},
},
});
server.route({
method: "GET",
path: "/logout",
handler: (request, h) => {
return "<pre> logged out successfully </pre>";
},
config: {
auth: {
mode: "required",
strategy: "session",
},
},
});
await server.start();
console.log("Server running on %s", server.info.uri);
};
process.on("unhandledRejection", (err) => {
console.log(err);
process.exit(1);
});
init();
- 主要言語
- 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