【发布时间】:2019-10-17 12:53:04
【问题描述】:
所以,正如标题所示,我正在寻找一种方法将我自己的自定义身份验证服务集成到解析服务器中,该解析服务器安装在 docker 容器中。这种身份验证基本上是 KeyCloak 的 OpenID 实现。
关键是我没有(我的架构最好不要)在我的本地机器上使用 express 提供解析服务器。
到目前为止,我一直在尝试的是搜索互联网,阅读问题,阅读 JavaScript 的解析服务器文档以及指南和其他东西以找出,我该如何实现它。
似乎我做什么都没关系,在每次测试结束时,我都会收到252 This authentication method is unsupported 错误! (即使我使用facebook、oauth、oauth2 等也会发生这种情况。
所以现在,docker-compose 服务看起来像这样:
parse-server:
image: parseplatform/parse-server
ports:
- "${SERVER_PORT}:1337"
restart: "always"
volumes:
- ./server/parse/custom-auth:/parse-server/custom-auth
depends_on:
- mongodb
links:
- mongodb:mongo
environment:
- PARSE_SERVER_APPLICATION_ID=${APP_ID}
- PARSE_SERVER_MASTER_KEY=${MASTER_KEY}
- PARSE_SERVER_DATABASE_URI=mongodb://mongo:${MONGO_PORT}/dev
- PARSE_SERVER_START_LIVE_QUERY_SERVER=1
- PARSE_SERVER_LIVE_QUERY={"classNames":${LIVE_QUERY_CLASSES}}
- PARSE_SERVER_MOUNT_GRAPHQL=${GQL_API}
- PARSE_SERVER_MOUNT_PLAYGROUND=${GQL_PLAYGROUND}
- PARSE_SERVER_AUTH_PROVIDERS={"swwwan-mail-auth":{"module":"/parse-server/custom-auth/swwwan-mail-auth/index.js"}}
以及登录/注册部分:
export const loginWithParse = async (account: IUserColumnTypes) => {
if (account.username === null || account.password === null) {
throw "validation failed";
}
// @ts-ignore
const loggedIn = await Parse.User.logInWith("swwwan.mail-auth", {
authData: {
id: "",
access_token: "",
},
});
console.log({ loggedIn });
//return await Parse.User.logIn(account.username, account.password);
};
登录/注册的另一种选择:
export const loginWithParse = async (account: IUserColumnTypes) => {
if (account.username === null || account.password === null) {
throw "validation failed";
}
const u = new Parse.User();
u._linkWith("swwwan-mail-auth", {
authData: {
id: "tester",
access_token: "sample_access_token",
},
})
.then(res => console.log(res))
.catch(e => console.log(e));
//return await Parse.User.logIn(account.username, account.password);
};
更新:通过使用第二种选择,我实际上得到了错误:
error: Parse error: Invalid key name: authData.swwwan-mail-auth.id {"code":105,"stack":"Error: Invalid key name: authData.swwwan-mail-auth.id
有没有办法让它工作?可能我在这里遗漏了一些东西。
tnx :)
【问题讨论】:
标签: javascript docker parse-platform docker-compose parse-server