标签: auth0-lock

Auth0 不会在页面刷新时为电子邮件/密码持续登录

我使用 Auth0 作为使用 React 的 SPA 的身份验证提供程序。我遵循了他们博客中的Auth0 react 教程这个更详细的教程

我目前只使用电子邮件/密码身份验证。并且身份验证按预期进行登录/注销,检索用户信息等。

但是,当我刷新页面时,isAuthenticated来自的值useAuth0总是返回 false。即使在isLoading解析为 true 之后,我也必须再次登录。

奇怪的是,这种行为不会在 Chrome 或 Firefox 上发生。它在 Brave 和 Safari 上失败。

我在 Auth0(另一个有类似问题的人)的论坛帖子中注意到,Auth0Provider应该authorize使用 拨打电话prompte=none,确实如此。它还202在页面加载后不久返回成功(但不会更改isAuthenticatedtrue)。此调用还设置了一个 cookie auth0.is.authenticated=true

authorize?client_id=VALUE&redirect_uri=VALUE&scope=openid%20profile%20email&response_type=code&response_mode=web_message&state=VALUE&nonce=VALUE&code_challenge=VALUE&code_challenge_method=S256&prompt=none&auth0Client=VALUE
Run Code Online (Sandbox Code Playgroud)

这是我检查身份验证状态的路线。该组件Auth0ProviderWithHistory按照 Auth0 教程中的建议封装在代码中。

export default function Routes() {
  const { isLoading, isAuthenticated } = useAuth0()

  const getDashboard = () => {
    //determine which dashboard to return …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs auth0 auth0-lock

11
推荐指数
1
解决办法
1420
查看次数

如何使用lock v11从auth0无密码获取刷新令牌?

我有一个有两页的老式angularJs应用程序.在这两个页面上,我都包含了auth0锁定脚本.

<script src="https://cdn.auth0.com/js/lock/11.9.0/lock.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

在这两个页面中,有一个具有以下js,它们指定允许用户登录的auth0锁定:

new Auth0LockPasswordless(configuration.id,configuration.domain,
{
    allowedConnections: ['email'],
    passwordlessMethod: "link",
    auth: {
        redirectUrl: configuration.redirectUrl,
        responseType: 'token id_token',
        params: {
            scope: 'openid profile email offline_access'
        }
    }
}).show();
Run Code Online (Sandbox Code Playgroud)

另一页负责在点击电子邮件中的链接后进行回拨.

var lock = new Auth0LockPasswordless(configuration.id, configuration.domain);

lock.on('authorization_error',
    function(authResult) {
        console.log("DEBUG::AUTHRESULT::", authResult);
});

lock.on('authenticated',
    function(authResult) {
        console.log("DEBUG::AUTHRESULT::", authResult);
});
Run Code Online (Sandbox Code Playgroud)

现在我已经设置offline_access了请求的范围,并且在我的本地环境中,在进行身份验证时会提示其他权限(因此它正在通过).但是,当我从lock.on('authenticated', function(authResult)..refreshToken 检查日志时始终为null.

网络上存在一些相互矛盾的文档,两种建议都是锁定并且不会返回刷新令牌.是否有人能够确认此代码是否应该导致有效的refreshToken?

javascript auth0 auth0-lock

10
推荐指数
1
解决办法
273
查看次数

带有Auth0的XCTestCase:如何关闭安全警报“ XXXX”要使用“ auth0.com”登录

因此,最近Apple引入了此提示:“ XXXX”要使用“ auth0.com”登录,其中“ XXXX”是ios应用程序名称。

在此处输入图片说明

当用户使用Auth0时,单击“使用Google登录”或“使用Facebook登录”时,将出现此警报/对话框。很好,但是在运行IOS UI测试时,使用通常的关闭系统对话框的方法时,该对话框不会消失:

func doUserLogin(_ app: XCUIApplication) {

    app.staticTexts["notLoggedInActivelabel"].tap()
    // this will bring up oauth0 login window in ios

    // setup a handler to dismiss the system alert
    let handler = self.addUIInterruptionMonitor (withDescription: "allow oauth") { (alert) -> Bool in
        // code should come here where the dialog is presented, 
        // but it never does ....   
        alert.buttons["Continue"].tap() // click Continue Button 
        return true
    }

    // click the login with GOOGLE button. This brings up dialog “XXXX” Wants …
Run Code Online (Sandbox Code Playgroud)

automated-tests ios auth0 xctestcase auth0-lock

7
推荐指数
1
解决办法
576
查看次数

如何为 Angular 应用程序设置 Auth0 配置?

我正在尝试在Angular 应用程序中使用Auth0,但是当我在 [https://manage.auth0.com/dashboard/] 中设置配置时,单击“保存更改”按钮时出现此错误

错误!有效负载验证错误:“对象未通过属性itiate_login_uri 上绝对-https-uri-or-empty 格式的验证:https://localhost:4200/en/signin”(启动登录 uri,必须是 https)。

如何解决这个错误?

auth0 angular auth0-lock

6
推荐指数
1
解决办法
2879
查看次数

从重定向角度 5 中获取查询参数

我的问题是我使用 auth0 作为我的身份验证服务,现在当用户登录并通过身份验证时,它会被重定向回我的回调 url,然后决定将用户发送到哪里现在我的问题是当你被重定向回你的回调时来自 auth0 的 url 在 url 字符串中有 queryParams,就像这样..

http://localhost:4200/account/login/callback#access_token="dsadsadsadsa dasdsaa"只是作为一个例子,但在一瞬间,查询字符串被删除,http://localhost:4200现在它离开了我试图使用这种方法获取查询参数

this.activatedRoute.queryParams.subscribe(params => {
    console.log(params);
});
Run Code Online (Sandbox Code Playgroud)

现在这应该可以工作,但是每次 console.log 都是一个空对象,我认为这是因为发生的 url 更改..

有什么方法可以在删除之前获取查询参数?

编辑

基本上发生的事情是我正在通过身份验证然后我被重定向到

localhost:4200/account/login/callback?acessToken="dasdasdaefssves"

但随后路线更改为

localhost:4200/account/login/callback

activatedRoute函数有机会运行之前没有查询参数!

任何帮助,将不胜感激!

javascript typescript auth0 angular auth0-lock

5
推荐指数
1
解决办法
1286
查看次数

如何使用 Cypress 和 Auth0 测试单页应用程序

我有一个隐藏在 Auth0 锁后面的单页应用程序,使用@auth0/auth0-spa-js。我想使用 Cypress 对其进行测试,因此我决定关注Auth0官方博客文章以及 Johnny Reilly博客文章

我能够使用建议的请求从 auth0 成功检索有效的 JWT 令牌。我不知道该怎么办:(

我面临的问题是,上述两种方法都依赖于应用程序在本地存储 JWT 令牌(在 cookie 或 localstorage 中)。然而,@auth0/auth0-spa-js使用不同的方法,我假设所有相关的 cookie/localstorage 都存储在 auth0 域中。

你有什么想法,如果有办法绕过它吗?

2018 年 7 月这里报告一个类似的问题,没有真正提供任何解决方案

auth0 cypress auth0-lock

5
推荐指数
1
解决办法
3911
查看次数