标签: auth0

在 ASP.NET Blazor Web Assembly 客户端应用程序中使用 Auth0 注销后的登录提示

我刚刚开始构建一个简单的 Web 程序集 ASP.NET 客户端 Web 应用程序,其身份验证由 Auth0 提供支持。

我发现有几篇文章可以引导您完成执行此操作所需的步骤,例如:https: //auth0.com/blog/what-is-blazor-tutorial-on-building-webapp-with-authentication /

不幸的是,由于其中许多内容都是编写的,因此 Blazor 客户端项目似乎已从针对 .NET Core 移植到 .NET Standard,因此无法安装所需的 NuGet 包:Microsoft.AspNetCore.Authentication.OpenIdConnect

相反,我找到了来自 Microsoft 的教程,该教程使用Microsoft.AspNetCore.Components.WebAssembly.Authentication它包装了处理身份验证流程所需的一些 Javascript 代码: https://learn.microsoft.com/en-us/aspnet/core/security/blazor/web assembly/standalone-with-authentication -library?view=aspnetcore-3.1

我设法让它工作,但是当我注销并再次登录时,应用程序会自动进行身份验证,而不会带我进入 Auth0 登录页面。根据OpenID Connect 规范,我需要发送一个可选prompt参数集来login强制显示登录屏幕(作为用户注销后我所期望的)。

上述Microsoft.AspNetCore.Authentication.OpenIdConnect库能够设置此参数:https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.openidconnect.openidconnectoptions.prompt ?view=aspnetcore-3.0

据我所知,WebAssembly 库没有:https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.web assembly.authentication.oidcprovideroptions?view=aspnetcore-3.1

有人知道解决方法吗?

Program.cs的如下:

public class Program
    {
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<App>("app");

            builder.Services.AddTransient(sp => new HttpClient { BaseAddress = …
Run Code Online (Sandbox Code Playgroud)

asp.net auth0 blazor blazor-client-side

3
推荐指数
1
解决办法
2265
查看次数

在auth0中获取accessToken

我正在使用auth0nextJS

我下一步想做:当用户添加他的凭据并登录时,他将被重定向到callbackAPI。

和这里

    import auth0 from '../../utils/auth0';

    export default async function callback(req, res) {
      try {
        await auth0.handleCallback(req, res, {
          redirectTo: '/'
        });
      } catch (error) {
        console.error(error);
        res.status(error.status || 400).end(error.message);
      }
    }
Run Code Online (Sandbox Code Playgroud)

我想根据令牌重定向用户。
如果应用程序是简单的用户或管理员,则解码令牌我将获取数据。

如果他是管理员,即使不是用户页面,他也应该被重定向到管理页面。

所以我做了这样的事情:

    import auth0 from '../../utils/auth0';

    export default async function callback(req, res) {
       const tokenCache = auth0.tokenCache(req, res);
       const { accessToken } = await tokenCache.getAccessToken();
       console.log(accessToken) 
      try {
        await auth0.handleCallback(req, res, { redirectTo: '/' });
      } catch (error) { …
Run Code Online (Sandbox Code Playgroud)

javascript authentication reactjs auth0 next.js

3
推荐指数
1
解决办法
6635
查看次数

如何在下一个js中使用auth0登录?

如何使用 auth0 登录下一个 js 应用程序?我按照 auth0 网站的快速入门进行操作,但在登录页面上收到此错误。

<a href="/api/auth/login">Login</a>

这是pages/api/[...auth0].js

import { handleAuth } from '@auth0/nextjs-auth0';

export default handleAuth();

Run Code Online (Sandbox Code Playgroud)

我在登录页面上收到此错误。

登录时出错

我在我的终端中得到了这个

OPError: expected 200 OK, got: 404 Not Found
    at processResponse (/home/madhav/Documents/Web Development/freelancing/frontend-affilboost/node_modules/openid-client/lib/helpers/process_response.js:48:11)
    at Function.discover (/home/madhav/Documents/Web Development/freelancing/frontend-affilboost/node_modules/openid-client/lib/issuer.js:252:22)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  error: 'expected 200 OK, got: 404 Not Found'
}

Run Code Online (Sandbox Code Playgroud)

我正在Failed to load resource, the server responded with code 500进入浏览器的控制台。

我究竟做错了什么?

reactjs auth0 next.js

3
推荐指数
1
解决办法
1621
查看次数

nextjs + auth / 该网站无法提供安全连接

我的项目中存在安全连接问题。下面是我的设置和代码: 在此输入图像描述 在此输入图像描述

怎么了?

ps 我基于本教程的代码: https://thetechhulk.com/auth0-and-next-js-authentication-complete-guide

auth0 next.js

3
推荐指数
2
解决办法
3803
查看次数

使用Firebase委派的Auth0

使用firebase委派进行Auth0登录

.controller('LoginCtrl', function($scope, auth, $state, store) {
      auth.signin({
        authParams: {
          // This asks for the refresh token
          // So that the user never has to log in again
          scope: 'openid offline_access',
          // This is the device name
          device: 'Mobile device'
        },
        // Make the widget non closeable
        standalone: true
      }, function(profile, token, accessToken, state, refreshToken) {
        // Login was successful
        // We need to save the information from the login
        store.set('profile', profile);
        store.set('token', token);
        store.set('refreshToken', refreshToken);
        auth.getToken({
          api: 'firebase'
        }).then(function(delegation) …
Run Code Online (Sandbox Code Playgroud)

firebase firebase-security auth0 firebase-authentication

2
推荐指数
1
解决办法
2139
查看次数

如何从django-oauth-toolkit令牌获取当前登录用户?

我正在使用Django和django-oauth-toolkit 为Auth0 构建一个通用的OAuth2授权服务器.我计划使用Django服务器来验证几个不同服务的用户,使用Auth0作为中介.

我有一个在应用程序经过身份验证后调用的视图,我需要该视图来返回当前登录用户的详细信息.

urls.py:

# Return current logged in user
(r'^user/current/?$',
 'my_app.views.current_user.get_user',
 {},
 'current_user'),
Run Code Online (Sandbox Code Playgroud)

意见/ current_user.py:

import json
from django.http import HttpResponse
from oauth2_provider.decorators import protected_resource


@protected_resource()
def get_user(request):
    user = request.user
    return HttpResponse(
        json.dumps({
            'username': user.username, 
            'email': user.email}),
        content_type='application/json')
Run Code Online (Sandbox Code Playgroud)

request.user 返回AnonymousUser,而不是令牌所属的用户.

如何访问与django-oauth-toolkit发出的令牌相关联的Django用户?

django oauth auth0 django-oauth

2
推荐指数
1
解决办法
2141
查看次数

验证节点PEM_read_bio_PUBKEY上的RS256 jwt是否失败

我正在尝试验证jwt使用该RS256算法的情况.使用hs256算法时一切正常

let opts = {
  audience: 'y',
  issuer: `https://x.auth0.com/`,
  algorithms: ["RS256"]
}

jwt.verify(payload.token, 'secret', opts, (err, decoded) => {
    if (err) {
        console.log("invalid token in iamonline service " + err.message);
        return;
    }
Run Code Online (Sandbox Code Playgroud)

我一直收到错误: PEM_read_bio_PUBKEY failed

虽然auth0文件要这样做,但它假设你使用的是快递,我不是.我在websocket上这样做,所以没有中间件.

恼人的一点HS256对我来说没问题,但auth0自定义登录表单似乎需要RS256.

node.js jwt json-web-token auth0

2
推荐指数
1
解决办法
3523
查看次数

在Auth0 Lock for Android中获得403不允许的用户代理

在我的Android应用程序中集成Auth0登录.对于这个集成,我正在关注这个 https://auth0.com/docs/libraries/lock-android

它之前的工作很好,但现在我面对403不允许的用户,而点击谷歌.

当我在谷歌搜索时,我发现这一点:谷歌自4月20日起决定阻止从嵌入式网页浏览访问以达到安全目的,这就是为什么用谷歌登录Auth0失败的原因.

iOS家伙使用以下方法解决了同样的问

但是在android中没有找到这个

如何解决这个问题.任何人都有这个想法.

我的代码:

compile 'com.auth0.android:lock:2.+'

Auth0 auth0 = new Auth0(getString(R.string.auth0_client_id), getString(R.string.auth0_domain));
            mLock = Lock.newBuilder(auth0, mCallback)
                    //Add parameters to the builder
                    .closable(true)
                    .build(this);
            startActivity(mLock.newIntent(this));

private LockCallback callback = new AuthenticationCallback() {
       @Override
       public void onAuthentication(Credentials credentials) {
          //Authenticated
       }

       @Override
       public void onCanceled() {
          //User pressed back
       }

       @Override
       public void onError(LockException error) {
          //Exception occurred
       }
   };
Run Code Online (Sandbox Code Playgroud)

表现:

<activity
  android:name="com.auth0.android.lock.LockActivity"
  android:label="@string/app_name"
  android:launchMode="singleTask"
  android:screenOrientation="portrait"
  android:theme="@style/MyLock.Theme">
    <intent-filter>
      <action android:name="android.intent.action.VIEW" />

      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />

      <data …
Run Code Online (Sandbox Code Playgroud)

android google-oauth google-oauth2 auth0 auth0-delegated-admin

2
推荐指数
3
解决办法
4552
查看次数

Auth0用户信息方法返回仅具有子属性的用户对象

我正在为我的角度应用程序构建身份验证,并且当有人登录时我试图从auth0获取userinfo.我使用auth0文档作为指导,我得到'用户'对象,但它只有子属性没有名称,电子邮件等.

Object {sub: "auth0|5**********7"}
Run Code Online (Sandbox Code Playgroud)

我尝试使用facebook,linkedin,google登录并在没有社交媒体的情况下注册,但结果只是'auth0 |' 部分变化.这是我的auth.service.ts:

auth0 = new auth0.WebAuth({
  clientID: 'myClientID',
  domain: 'myDomain.auth0.com',
  responseType: 'token id_token',
  audience: 'https://myDomain.auth0.com/userinfo',
  redirectUri: 'http://localhost:4200/',
  scope: 'openid'
})

handleAuthentication(): void {
  this.auth0.parseHash((err, authResult) => {
    if (authResult && authResult.accessToken && authResult.idToken) {
      window.location.hash = '';
      this.setSession(authResult);
      this.router.navigate(['/dersler']);

      // This is for getting user info after authentication (taken from the auth0 docs but revised)
      this.auth0.client.userInfo(authResult.accessToken, function(err, user) {
      // This method will make a request to the /userinfo endpoint 
      // and return the user …
Run Code Online (Sandbox Code Playgroud)

authentication auth0 angular

2
推荐指数
1
解决办法
1377
查看次数

auth0和IdentityServer有什么区别?

似乎这两个都提供了授权和身份验证。

两者都使用OpenID connect。

identity oauth-2.0 openid-connect auth0 identityserver3

2
推荐指数
1
解决办法
797
查看次数