firebase-admin SDK中的自定义授权?

发布于 2025-02-11 10:50:11 字数 1295 浏览 1 评论 0 原文

我一直在寻找讨论组查找与我的域服务器端生成SignWithemaillink的任何提示。

是否可以使用我的域中自定义服务器端中的signin链接?还是在 client app 中只是可能吗?

使用您的身份提供商更新回调URL以使用您的自定义域而不是默认域。例如,更改 https://myproject.firebaseapp.com/__/auth/auth/auth/auth/auth/handler https://auth.mycustomgomain.com/__/auth/auth/handler

这是我的实际工作,但我更喜欢最干净的解决方案。

let link = await getAuth().generateSignInWithEmailLink(email, actionCodeSettings);

if(link.startsWith("https://myproject.firebaseapp.com")) {
  link = link.replace("https://myproject.firebaseapp.com", process.env.AUTH_URL);
}

I have been looking to the firebase-admin SDK documentation and the discussions groups and can not find any tips to generate a signInWithEmailLink with my domain server-side.

Is it possible to custom the signIn link in server-side with my domain? Or is it just possible in client app?

Update the Callback URL with your identity provider to use your custom domain instead of the default domain. For example, change https://myproject.firebaseapp.com/__/auth/handler to https://auth.mycustomdomain.com/__/auth/handler.

This is my actual work around but I would prefer a cleanest solution.

let link = await getAuth().generateSignInWithEmailLink(email, actionCodeSettings);

if(link.startsWith("https://myproject.firebaseapp.com")) {
  link = link.replace("https://myproject.firebaseapp.com", process.env.AUTH_URL);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不气馁 2025-02-18 10:50:11

您的方法实际上是一个很好的方法,但是可以替换普通的字符串。尝试使用 url 类,它更清晰且容易出错。

const link = await getAuth().generateSignInWithEmailLink(email, actionCodeSettings);

const linkUrl = new URL(link);
const authUrl = new URL(process.env.AUTH_URL);
linkUrl.hostname = authUrl.hostname;

// you will get your custom domain replaced in the generated url
console.log(linkUrl.toString());

Your approach is actually a good one, but it's a bit rough with a plain string replacement. Try using the URL class, it is clearer and less error-prone.

const link = await getAuth().generateSignInWithEmailLink(email, actionCodeSettings);

const linkUrl = new URL(link);
const authUrl = new URL(process.env.AUTH_URL);
linkUrl.hostname = authUrl.hostname;

// you will get your custom domain replaced in the generated url
console.log(linkUrl.toString());
椒妓 2025-02-18 10:50:11

转到模板页面 ”。
这样做的进步是,它不仅会影响firebase管理员。

Go to the templates page, click edit and then click "customize domain".
The advance of doing so is that it not only affects Firebase admin.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文