我想要使用angular2-jwt我的ionic2应用程序,我一直在努力No provider for AuthConfig!
这是我的app.ts:
import {AuthHttp, AuthConfig} from 'angular2-jwt';
import {Http} from 'angular2/http'
@App({
template: '<ion-nav [root]="rootPage"></ion-nav>',
config: {}, // http://ionicframework.com/docs/v2/api/config/Config/
providers: [
provide(AuthHttp, {
useFactory: (http) => {
return new AuthHttp(new AuthConfig(), http);
},
deps: [Http]
}),
AuthHttp
]
})
Run Code Online (Sandbox Code Playgroud)
我在我的login.ts页面上使用它:
import {AuthHttp, AuthConfig} from 'angular2-jwt';
@Page({
templateUrl: 'build/pages/login/login.html',
directives: [IONIC_DIRECTIVES]
})
export class LoginPage {
constructor(private authHttp: AuthHttp){
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Auth0 进行身份验证并获取用户数据。
import json
import requests
payload = {
'grant_type': 'password',
'username': '********',
'password': '********',
'client_id': '********',
'connection': 'Username-Password-Authentication',
'scope': 'openid'
# 'scope': 'openid, read:clients, read:client_keys'
# 'scope': 'read:clients'
}
base = 'https://********.auth0.com'
url = base + '/oauth/ro'
response = requests.post(url, data=payload)
response = json.loads(response.content)
headers = {"Authorization": "bearer " + response["id_token"]}
response = requests.get(base + '/api/v2/clients/joebloggs', headers=headers).json()
print response
Run Code Online (Sandbox Code Playgroud)
我不断得到的是
{u'errorCode': u'insufficient_scope', u'message': u'Insufficient scope, expected any of: read:clients,read:client_keys', u'error': u'Forbidden', u'statusCode': 403}
Run Code Online (Sandbox Code Playgroud)
究竟有什么问题,该怎么办?
我有一个连接到ASP.NET Core后端的Aurelia SPA.我使用Auth0进行身份验证(使用aurelia-auth,而不是Auth0 Lock小部件).
我目前直接使用Auth0登录,而不是使用SPA.这给了我一些问题,因为我的API中的Auth0实现需要id_token而不是access_token.可以通过告诉aurelia-auth将id_token用作访问令牌来传递此问题.但这使Auth0和Aurelia应用程序之间的进一步通信变得复杂化.Auth0期望access_token用于用户配置文件调用等.
我应该通过自己的API进行身份验证吗?或者我应该在Aurelia中制作两个不同的fetch-clients?一个用于调用我的API(使用id_token),另一个用于调用Auth0 API(使用access_token).
我正在尝试按照他们的教程中的描述移动Auth0登录功能.如果我像这样使用它,我能够使它工作:
<button className="btn" onClick={this.props.route.auth.login.bind(this)}>test</button>
Run Code Online (Sandbox Code Playgroud)
但如果我设置按钮来调用一个函数我在上面定义了渲染函数,如下所示:
login() {
this.props.route.auth.login.bind(this);
}
Run Code Online (Sandbox Code Playgroud)
并改变onclick如下:
onClick={this.login()}
Run Code Online (Sandbox Code Playgroud)
要么
onClick={() => this.login()}
Run Code Online (Sandbox Code Playgroud)
然后auth登录模式永远不会打开,我没有收到任何错误.另外我添加了一个console.logto login(),我可以在控制台中看到它,但实际的登录模式永远不会打开?它适用于第一个示例,但不适用于其他示例.
我试图将其转换为函数的原因是因为我想稍后将登录函数传递给子组件,而我无法这样做,我相信这是阻止我的根本问题.
我正在学习角度2,并且尝试创建一种方案,在该方案中向用户显示主页,并使用Auth0登录到我的应用程序,之后我希望用户从身份验证服务中重定向到仪表板页面。
import { Injectable } from '@angular/core';
import { tokenNotExpired } from 'angular2-jwt';
import { myConfig } from './auth.config';
import {Router} from "@angular/router";
// Avoid name not found warnings
declare var Auth0Lock: any;
@Injectable()
export class Auth {
// Configure Auth0
lock = new Auth0Lock(myConfig.clientID, myConfig.domain, {});
constructor(private router:Router) {
// Add callback for lock `authenticated` event
this.lock.on('authenticated', (authResult) =>
{
this.lock.getProfile(authResult.idToken,function (error: any, profile: any)
{
if(error)
{
throw new Error;
}
localStorage.setItem('id_token', authResult.idToken);
localStorage.setItem('profile', JSON.stringify(profile));
this.router.navigate(['/dashboard']);
});
}); …Run Code Online (Sandbox Code Playgroud) 从理论上讲,如果我想将我的 Users 数据库表基于 Auth0 返回的数据并根据 Auth0 用户配置文件 ID 在我的 Users 表中维护一个唯一 ID,我是否会遇到 Auth0 用户 ID 已更改的情况?如果是这样,用户id更改的情况是什么?
因此,我想在所有使用auth服务器的产品中进行单点登录,但这不仅适用于员工,还应该像auth0一样使用keycloak?
在我的Spring Boot应用程序中,我正在使用Auth0来管理对我的其余api的访问。
除了Auth0外,scope我还想向每个用户添加一个角色,这反过来又将提供一个访问控制的附加层,在该层中,低特权用户将无法访问特定的API。
我一直在阅读有关自定义规则和授权扩展的信息,但我不太了解什么是适合我的正确实现。
这是我的WebSecurityConfigurerAdapter代码段:
因此,基本上,我只希望例如“ ADMIN”才能访问/test/**
@Override
protected void configure(HttpSecurity http) throws Exception {
JwtWebSecurityConfigurer
.forRS256(configBean.getAuth0ApiAudience(), configBean.getAuth0Issuer())
.configure(http)
.authorizeRequests()
.antMatchers(HttpMethod.GET, "/test/**").hasAuthority("read:test")
.anyRequest().authenticated();
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激!
我正在开发一个使用 auth0 进行身份验证的 Angular2 应用程序。我使用 auth0 锁定小部件来验证用户。
现在,我想使用auth0-js而不是锁定小部件进行身份验证。我按照本指南添加auth0-js到应用程序中。
添加后auth-js,当新用户尝试登录应用程序时,Auth0 会向用户显示以下同意屏幕。
我希望用户能够直接访问我的应用程序,而无需接受同意屏幕。此对话框中提出的同意问题可能会让用户感到困惑,因为它提到了租户。
我在寻找解决方案的时候,在各个地方提到的解决方案是让客户成为first party客户。但是,我在管理控制台中找不到任何地方使客户端成为first party客户端。
如何禁用此同意屏幕?
以下是auth-js我在应用程序中使用的配置。
auth0 = new auth0.WebAuth({
clientID: 'my_client_id',
domain: 'my_domain.auth0.com',
responseType: 'token id_token',
audience: 'https://my_domain.auth0.com/userinfo',
redirectUri: window.location.origin + '/auth_loading',
scope: 'openid'
});
Run Code Online (Sandbox Code Playgroud) 我以为是PassportJSvs Auth0。。现在我刚刚发现有一个叫做passport-auth0的PassportJS 策略——这让我很困惑。有人可以向我解释一下吗?
这里说的是 Passport is authentication middleware for Node.js that can be unobtrusively dropped into any Express-based web application.- 我不确定我是否理解这一点?