【发布时间】:2019-04-02 19:41:28
【问题描述】:
我在 react 中创建了一个应用程序,并且我正在使用 ADAL 在 Azure Active Directory 中进行身份验证,因此每次有人访问我的站点时,他都必须登录。
我必须记录(向我的 API 发送 POST 请求)所有连接和断开连接(当用户单击按钮注销时)。
身份验证由 ADAL 管理,所以我不知道将我的代码放在哪里来处理这个...
import { AuthenticationContext, adalFetch, withAdalLogin } from 'react-adal';
export const adalConfig = {
instance: 'https://login.microsoftonline.com/',
tenant: '3v824f55-8461-4eab-9659-81cce12dfa04',
clientId: '33h87014-dff8-4406-84ce-2608f7173fe2',
endpoints: {
api: '14653b62-d8444-4e7a-9362-d7267et30a0d',
},
postLogoutRedirectUri: window.location.origin,
cacheLocation: 'localStorage',
callBack:callBackFunction
};
export const authContext = new AuthenticationContext(adalConfig);
export const adalApiFetch = (fetch, url, options) =>
adalFetch(authContext, adalConfig.endpoints.api, fetch, url, options);
export const withAdalLoginApi = withAdalLogin(authContext, adalConfig.endpoints.api);
function callBackFunction(errorDesc, token, error, tokenType)
{`enter code here`
alert("Problem wit`enter code here`h the connection ! ");
}
export const getToken = () => {
return authContext.getCachedToken(authContext.config.clientId);
};
这是我的 adal.config 文件(这不是真实值)
有没有人有任何想法或曾经遇到过这个问题?
提前谢谢:)
【问题讨论】:
-
如果它解决了您的问题,请您标记以下答案。
标签: reactjs authentication adal