第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

具有 Express 會(huì)話問題的節(jié)點(diǎn)

具有 Express 會(huì)話問題的節(jié)點(diǎn)

阿晨1998 2022-12-22 09:42:19
我使用以下有效的代碼,但是在幾次成功調(diào)用(5-10) 之后,我們有時(shí)會(huì)收到內(nèi)部服務(wù)器錯(cuò)誤:req.session["oidc:accounts.rvm.com"] is undefined我已經(jīng)嘗試了所有的latest開源版本。Error: did not find expected authorization request details in session, req.session["oidc:accounts.rvm.com"] is undefinedat /opt/node_app/app/node_modules/openid-client/lib/passport_strategy.js:125:13at OpenIDConnectStrategy.authenticate (/opt/node_app/app/node_modules/openid-client/lib/passport_strategy.js:173:5)at attempt (/opt/node_app/app/node_modules/passport/lib/middleware/authenticate.js:366:16)at authenticate (/opt/node_app/app/node_modules/passport/lib/middleware/authenticate.js:367:7)at /opt/node_app/app/src/logon.js:92:7 *******at Layer.handle [as handle_request] (/opt/node_app/app/node_modules/express/lib/router/layer.js:95:5)at next (/opt/node_app/app/node_modules/express/lib/router/route.js:137:13)at Route.dispatch (/opt/node_app/app/node_modules/express/lib/router/route.js:112:3)at Layer.handle [as handle_request] (/opt/node_app/app/node_modules/express/lib/router/layer.js:95:5)at /opt/node_app/app/node_modules/express/lib/router/index.js:281:22我的堆棧代碼是:at /opt/node_app/app/src/logon.js:92:7這是代碼的結(jié)尾:})(req, res, next);   // here is line 92 but not sure if it's related 這是完整的代碼(我通過了app它只是一個(gè)快速服務(wù)器):索引.jsconst express = require('express');const logon = require('./logon');const app = express();const port = process.env.PORT || 4000;logon(app)  .then(() => {    console.log('process started');  });app.use(express.json());app.listen(port,  () => console.log(`listening on port: ${port}`));有時(shí)當(dāng)我調(diào)試時(shí),我看到函數(shù)正在運(yùn)行,GetUsers這是一個(gè)異步函數(shù)并停止在 中})(req, res, next);,可能是異步問題。我們想在 prod 中使用這段代碼,而不是以前的 Java 實(shí)現(xiàn)。如果我可以對(duì) oidc 使用另一種技術(shù),請(qǐng)告訴我。
查看完整描述

4 回答

?
米脂

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超3個(gè)贊

這個(gè)問題似乎是一個(gè)競(jìng)爭(zhēng)條件,如果你碰巧同時(shí)收到兩個(gè)請(qǐng)求,在飛行中,當(dāng)一個(gè)請(qǐng)求完成時(shí),它會(huì)在另一個(gè)有機(jī)會(huì)完成之前清除會(huì)話 cookie。不管怎樣,您不是唯一遇到此問題的人。


不過,我認(rèn)為這不是庫(kù)本身的問題,我認(rèn)為問題更多在于會(huì)話庫(kù)。您可能想嘗試將/選項(xiàng)設(shè)置為express-session的庫(kù),并檢查您是否仍然看到相同的問題,例如saveUninitializedresavefalse


const session = require('express-session');

...

app.use(session({

  saveUninitialized: false,

  resave: false

});

cookie-session此庫(kù)與您使用的庫(kù)之間的唯一區(qū)別是express-session僅將會(huì)話 ID 存儲(chǔ)在 cookie 中,數(shù)據(jù)存儲(chǔ)在服務(wù)器端。如果您發(fā)現(xiàn)它有效,那么您可以考慮使用更具生產(chǎn)級(jí)的商店(默認(rèn)設(shè)置是使用內(nèi)存中的商店運(yùn)行)。


FWIW - 你只需要配置一次策略,看看它做了什么,如果它是問題的一部分我會(huì)感到驚訝但我會(huì)修復(fù)它以防萬一


查看完整回答
反對(duì) 回復(fù) 2022-12-22
?
FFIVE

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊

我們遇到了類似的問題,但我們有更多的間歇性行為,我們?cè)?Safari 上登錄時(shí)出現(xiàn)錯(cuò)誤,但在 Chrome 上卻沒有。

據(jù)我了解,這是因?yàn)闀?huì)話 cookie 在我們第一次進(jìn)行身份驗(yàn)證時(shí)被設(shè)置,它存儲(chǔ)statecode-verifier(僅當(dāng)使用 PKCE 流時(shí))和 OIDC 客戶端驗(yàn)證身份驗(yàn)證所需的其他值。

但是,當(dāng) /callback URL 被命中時(shí),瀏覽器會(huì)將此會(huì)話 cookie 發(fā)送到服務(wù)器以完成身份驗(yàn)證。

每當(dāng)未發(fā)送此 cookie 時(shí),就會(huì)發(fā)生此錯(cuò)誤,因?yàn)榛卣{(diào)假定這是一個(gè)新請(qǐng)求并且它崩潰了......

對(duì)我們來說,這有兩種表現(xiàn)方式。

  1. Cookie { 同一站點(diǎn):'Lax' 安全:true }

    適用于 chrome,但這不適用于 safari

  2. Cookie { 同一站點(diǎn):'無' 安全:true }

    適用于 chrome 和 safari

這需要在 express-session 中間件上設(shè)置(抱歉,我不確定所需的語法)


查看完整回答
反對(duì) 回復(fù) 2022-12-22
?
桃花長(zhǎng)相依

TA貢獻(xiàn)1860條經(jīng)驗(yàn) 獲得超8個(gè)贊

一種想法是,如果您決定啟用會(huì)話,那么您需要在 passport.session() 之前使用 express.session() 以確保以正確的順序恢復(fù)用戶的登錄會(huì)話。

看這篇文章


查看完整回答
反對(duì) 回復(fù) 2022-12-22
?
波斯汪

TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超4個(gè)贊

使用瀑布異步功能可能對(duì)此有所幫助。只需將 app.get 路由功能替換為以下代碼即可。當(dāng)我們必須運(yùn)行依賴于前一個(gè)任務(wù)的輸出的任務(wù)時(shí),Waterfall 會(huì)很有幫助。


    app.get('/redirect', async (req, res, next) => {

        await passport.authenticate('oidc',

            async.waterfall([

                function (err,user) {

                    // print second log

                    console.log('2. ------------redirect Called!------------');

                    if (err) {

                        console.log(`Authentication failed: ${err}`);

                        return next(err);

                    }

                    if (!user) {

                        return res.send('no identity');

                    }


                    req.login(user, async (e) => {

                        if (e) {

                            console.log('not able to login', e);

                            return next(e);

                        }

                        try {

                            const url = await azpi.GetUsers(user.id_token);

                            // print last log

                            console.log('3. ------------user process finished successfully----');

                            return res.redirect(url);


                        } catch (er) {

                            res.send(er.message);

                        }

                    });

                }

            ], function (err) {

                if (err) return next(err);  //here you can check error

            })   

        );

    });


查看完整回答
反對(duì) 回復(fù) 2022-12-22
  • 4 回答
  • 0 關(guān)注
  • 132 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)