我正在开发一个Objective-c iOS应用程序.我想使用auth0进行身份验证(https://auth0.com/),我想将Firebase用于数据库后端.
我已经浏览了所有auth0文档,并且我已经获得了身份验证:
Facebook,Google +,Twitter,自我注册.
问题:在我需要将身份验证模型与Firebase集成时,文档有点下降,它给了我这一页,我现在还不确定.有没有人之前做过这种整合,你能带领我走这条路吗?我对此有点新意.
Blockquote配置令牌内容
与在dahsboard中注册的任何其他API一样,Auth0将通过委派端点发出Firebase令牌.这允许您将令牌换成另一个令牌.
Firebase令牌的内容按约定生成,复制委派调用中使用的输入令牌中firebase_data属性下包含的所有属性.
您可以使用以下规则轻松生成这些内容:
user.firebase_data = {
user_id: new Buffer(user.email).toString('base64'),
company: !user.isSocial ? context.connection.replace(/\./g, '-') : null,
foo: 'bar'
};
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,将在调用委托endopint之后生成两个属性user_id和company,并且两个属性都将可供Firebase使用.
大段引用
Auth0提供了两个JWT库,一个用于Node:node-jsonwebtoken,另一个用于Java:java-jwt.
我创建了私钥/公钥对,并在Node中使用node-jsonwebtoken成功使用它:
var key = fs.readFileSync('private.key');
var pem = fs.readFileSync('public.pem');
var header = {...};
var payload = {...};
header.algorithm = "RS256";
var message = jsonwebtoken.sign(payload, key, header);
var decoded = jsonwebtoken.verify(message, pem, {algorithm: "RS256"});
Run Code Online (Sandbox Code Playgroud)
但是我发现用java-jwt在Java中没有办法做同样的事情.
任何人都有一个如何在Java中使用私有/公共密钥用于JWT的工作示例?
我在反应应用程序中使用auth0进行LinkedIn身份验证.我在设置localhost:3000/upload中设置了回调网址,在用户登录后localhost:3000/login跳转,他们将重定向到localhost:3000/upload.但是,我总是收到此错误:url localhost:3000/login不在回调网址列表中.为什么auth0会在登录后返回到您刚刚登录的页面.不应该是一些不同的URL.它对我来说没有意义.
编辑:
export default class AuthService {
constructor(clientId, domain) {
// Configure Auth0
const options = {
allowedConnections: ['linkedin'],
auth: {
params: {responseType: 'code'}
}
};
this.lock = new Auth0Lock(clientId, domain, options)
// Add callback for lock `authenticated` event
this.lock.on('authenticated', this._doAuthentication.bind(this))
// binds login functions to keep this context
this.login = this.login.bind(this)
this.loggedIn = this.loggedIn.bind(this)
}
_doAuthentication(authResult){
// Saves the user token
console.log(authResult);
this.setToken(authResult.idToken)
this.lock.getProfile(authResult.idToken, (error, profile) => {
if (error) { …Run Code Online (Sandbox Code Playgroud) 我有一个用例来使用Nodejs修改用户元数据.我找不到任何关于如何做的适当文件.所以,我想用其余的api来修改用户数据.我从控制台创建了一个API,并将观众添加为" http:// localhost:8080 ",授权我的现有客户端并提供"update:user","read:user"范围.我能够成功创建access_token但我无法进行API调用来读取/更新用户数据.它显示"观众不好".请注意这个错误(在这个问题上找不到合适的文档).
我有一个Android应用程序.它与一个REST API开发的连接Jersey.我的REST端点由令牌保护.以下是我如何生成它们.
Algorithm algorithm = Algorithm.HMAC256(secret);
String token = JWT.create()
.withClaim("userName","myusername)
.withExpiresAt(expirationDate)
.sign(algorithm);
Run Code Online (Sandbox Code Playgroud)
以下是我验证令牌的方法
public boolean validateTokenHMAC256(String token, String secret) throws UnsupportedEncodingException, JWTVerificationException
{
Algorithm algorithm = Algorithm.HMAC256(secret);
JWTVerifier verifier = JWT.require(algorithm)
.build(); //Reusable verifier instance
DecodedJWT jwt = verifier.verify(token);
Claim usernameClaim = jwt.getClaim("username");
String username = usernameClaim.asString();
System.out.println(username);
return true;
}
Run Code Online (Sandbox Code Playgroud)
在我的REST API中,我有一个过滤器,该过滤器检查每个请求以查看令牌是否原样.下面是代码.
@Secured
@Provider
@Priority(Priorities.AUTHENTICATION)
public class AuthenticationFilter implements ContainerRequestFilter{
//private static String authorizationSecret = "ZXW24xGr9Dqf9sq5Dp8ZAn5nSnuZwux2QxdvcH3wQGqYteJ5yMTw5T8DBUJPbySR";
public AuthenticationFilter()
{
System.out.println("test printing");
}
@Override
public …Run Code Online (Sandbox Code Playgroud) 我正在使用Actions on Google(在手机上Google Assistant)并使用它Account Linking登录Auth0(登录窗口:
图像).
但是,我想从我想要的地方注销,Auth0这样我就可以从头开始测试整个过程.
我写了下面的源代码Python和Flask下面的Auth0文档(https://auth0.com/docs/logout).
from flask import Flask, render_template, request, jsonify
import requests
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def index():
session['user'] = 'Poete_Maudit'
data = request.get_json()
if data is not None:
action = data["queryResult"]["action"]
else:
return 'HERE'
# Triggers actions.intent.SIGN_IN which leads to Auth0
if (action == 'sign'):
return jsonify({"payload": {
"google": {
"expectUserResponse": …Run Code Online (Sandbox Code Playgroud) 我有一个问题,我已经创建了一个有角度的PWA,我的应用程序使用auth0-lock作为其身份验证,现在我的问题是..当您单击其中一个单一登录选项(例如Google)时,您将被取出PWA和野生动物园,有什么办法可以阻止这个?
我已经尝试将此代码放在我的index.html中
<!-- Prevent app from opening new safari page -->
<script type="text/javascript">
(function(document,navigator,standalone) {
// prevents links from apps from oppening in mobile safari
// this javascript must be the first script in your <head>
if ((standalone in navigator) && navigator[standalone]) {
var curnode, location=document.location, stop=/^(a|html)$/i;
document.addEventListener('click', function(e) {
curnode=e.target;
while (!(stop).test(curnode.nodeName)) {
curnode=curnode.parentNode;
}
// Condidions to do this only on links to your own app
// if you want all links, use if('href' in curnode) instead.
if('href' …Run Code Online (Sandbox Code Playgroud) 注意:目前不是Auth0用户,但我正在调查其可行性,以解决我们正在努力解决的问题.
问题:我的公司希望在我们的网站和第三方应用程序之间创建一种"通用"登录功能.更详细一点:
我们通过一个平台销售强度和调节计划,用户可以通过该平台登录我们的锻炼.该平台归我们的业务合作伙伴所有.我们的锻炼计划并不是他们申请的唯一计划,因为他们还有其他提供锻炼计划的公司.
目前,我们有一个网站(WordPress),我们希望实现单点登录功能,以便在我们的合作伙伴应用程序上订阅我们的锻炼计划的用户可以使用相同的登录凭据登录我们的网站.我们不希望我们的客户必须为我们的网站创建新的登录,因为他们已经(技术上)我们的合作伙伴平台上的客户.
看起来我们的合作伙伴需要在他们身边(以及我们网站上的我们)实施auth0,但这是否有意义?从他们的结果来看,他们需要以某种方式将我们所有的用户分成一个单独的数据库,仅供我们的用户使用吗?我更想了解,如果这是他们无需向后弯腰为我们做的东西,能够我们自己和我们的合作伙伴之间,知道我们是不是他们的唯一客户.
谢谢!
当我们为 localhost 构建 Angular SPA 时,它运行良好。
在我们的开发环境中,此错误会蔓延到 DevTool 控制台并破坏一切:错误错误:未捕获(承诺):类型错误:无法读取未定义的属性“摘要”
TypeError: Cannot read property 'digest' of undefined
at N (auth0-spa-js.production.js:1)
at ie.<anonymous> (auth0-spa-js.production.js:1)
at Generator.next (<anonymous>)
at auth0-spa-js.production.js:1
at new ZoneAwarePromise (zone-evergreen.js:876)
at t (auth0-spa-js.production.js:1)
at ie.loginWithRedirect (auth0-spa-js.production.js:1)
at AuthGuard.<anonymous> (auth.guard.ts:22)
at Generator.next (<anonymous>)
at fulfilled (environment.ts:11)
at resolvePromise (zone-evergreen.js:797)
at new ZoneAwarePromise (zone-evergreen.js:879)
at t (auth0-spa-js.production.js:1)
at ie.loginWithRedirect (auth0-spa-js.production.js:1)
at AuthGuard.<anonymous> (auth.guard.ts:22)
at Generator.next (<anonymous>)
at fulfilled (environment.ts:11)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:34195)
at ZoneDelegate.invoke (zone-evergreen.js:358)
Run Code Online (Sandbox Code Playgroud)
我想这一定是关于构建过程,一些不同的标志,但我无法确切地弄清楚是哪个。
我正在尝试将具有 Auth0 身份验证的 Next.js 应用程序移动到新的应用程序路由器。我了解服务器组件无法写入 cookie 的限制,但我收到一条令人困惑的消息。
我的理解是,如果我需要获取服务器组件上的用户信息,我需要使用'getSession'from 的函数'@auth0/nextjs-auth0',该函数不适用于客户端组件。
但是,每次我调用它时,服务器控制台都会记录以下消息(未标记为错误或警告):"nextjs-auth0 is attempting to set cookies from a server component"。
我不想设置任何cookie,只是获取用户信息。谁能帮助我理解为什么这个调用使'getSession'组件设置cookie?另外,如果我并没有真正尝试设置 cookie,忽略此消息是否安全?
提前致谢。
添加代码:完整的解决方案有点复杂,但这段代码说明了我的问题。这是一个简单的 SSR 组件,它从服务器会话中获取用户名(按照 Auth0 的格式指定):
import { getSession } from '@auth0/nextjs-auth0';
export default async function Profile() {
const session = await getSession();
return (
<div>
HELLO {session?.user?.name}
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,每次getSession调用服务器控制台都会发出消息"nextjs-auth0 is attempting to set cookies from a server component"。
我没有明确尝试设置cookie,只是获取用户的信息。我想了解为什么会发生这种情况以及忽略该消息会产生什么影响。
再次提前感谢您的帮助。