hapi js social login session management
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
- Ambito
- authentication, backend
Direzione di ricerca
Inizia leggendo la configurazione dell’autenticazione e confrontando le strategie utilizzate da /auth/google e /logout. Riproduci il 401 con la configurazione indicata di Node 12.16.1, Hapi 11.0.2, Bell e Cookie, quindi traccia il motivo per cui la sessione Cookie stabilita non viene accettata; il lavoro è completato quando viene documentata la modifica di configurazione necessaria.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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();
- Lingua principale
- JavaScript
- Stelle
- 229
- Fork
- 99
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hapijs/cookie
-
support
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
ttl和keepAlive功能存在bugApertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
-
feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
support
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
support
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
Tutte le issue di hapijs/cookie
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
obsidianmd/obsidian-help#1169 ·
I maintainer di solito rispondono entro 2 giorni
-
[docs] RELEASE.md: wrong branch name, no check that the prepare PR merged with the right subject, manual publish stepForse già presa @albertteoh l’ha presa oggi. Apertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
jaegertracing/jaeger-ui#4739 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
keepassxreboot/keepassxc-browser#3159 · 1 commento ·
-
Add: ESP 2 RSApertaapproved check:passed feeds:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 67/100