我已經使用開放 ID 連接實作了 Azure SSO,一旦用戶使用辦公室帳戶登錄,我就會將用戶重定向到我的門戶主頁。
問題是由于重定向 URL(localhost:443/abc/test.aspx) 是我們必須放置的常量,我無法弄清楚如何保留用戶在登錄之前所在的 URL(例如 localhost:443/abc /test.aspx#/item/30176)。SSO 登錄后,它只將我重定向到 localhost:443/abc/test.aspx,我想登陸 localhost:443/abc/test.aspx#/item/30176(30176 是可變專案 ID)
如果狀態是唯一的出路。我找不到如何使用它。任何實施參考都會非常有幫助
uj5u.com熱心網友回復:
考慮使用 cookie 來記住原始 URL。用戶驗證后重定向它。
uj5u.com熱心網友回復:
? 您當然可以為此目的使用'state' 引數來將成功驗證后的用戶重定向到登錄前的同一頁面,但它需要在'MSAL.js' 腳本中發送的驗證請求中進行配置。state 引數還可以用于在重定向之前對應用程式狀態的資訊進行編碼。您可以將用戶在應用程式中的狀態(例如他們所在的頁面或視圖)作為此引數的輸入傳遞。MSAL.js 庫允許您將自定義狀態作為請求物件中的狀態引數傳遞,如下所示:-
// Request type
export type AuthenticationParameters = {
scopes?: Array<string>;
extraScopesToConsent?: Array<string>;
prompt?: string;
extraQueryParameters?: QPDict;
claimsRequest?: string;
authority?: string;
state?: string;
correlationId?: string;
account?: Account;
sid?: string;
loginHint?: string;
forceRefresh?: boolean;
};
有關在 Azure AD B2C 重定向鏈接中包含此引數的更多詳細資訊,您可以參考以下檔案鏈接:-
https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-js-pass-custom-state-authentication-request
https://docs.microsoft.com/en-us/azure/active-directory-b2c/authorization-code-flow
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/407502.html
標籤:
下一篇:python中的URL回圈
