Server中使用本地通行证进行身份验证

Server中使用本地通行证进行身份验证

本文介绍了如何在Composer Rest Server中使用本地通行证进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 passport-local 对用户进行身份验证,以便像其他人一样登录composer rest服务器护照策略(例如passport-githubpassport-google).

I want to use passport-local to authenticate user to login into composer rest server like other passport strategies ( e.g passport-github,passport-google).

所以我首先尝试像这样设置COMPOSER_PROVIDER变量

So first I try to set COMPOSER_PROVIDER variable like this

"local": {
    "provider": "local",
    "module": "passport-local",
    "usernameField": "username",
    "passwordField": "password",
    "authPath": "/auth/local",
    "successRedirect": "/",
    "failureRedirect": "/"}

然后我在docker中运行服务器(使用mongo作为持久数据源)并在数据库集合中添加一些用户

Then i run the server in docker (with mongo as persisted datasource) and add some user in database collection

问题是我需要使用此通行证的下一步是什么,因为我运行了此命令并且仍然会收到401 Unauthorized

The question is what's next step that i need to use this passport.Because i run this command and still get response with 401 Unauthorized

使用这本护照还不够吗?我是否需要启动另一项服务来本地验证此登录名(例如GitHub oAuth Application)?

Is it not enough to use this passport? Does i need to start another service to locally authenticate this login (e.g. GitHub oAuth Application )?

推荐答案

可以根据您的要求基于环回框架自定义composer-rest-server.

It is possible to customize your composer-rest-server, based on the loopback framework, according to your requirements.

我建议您从官方文档中阅读本教程.

I suggest to read this tutorial from the official documentation.

https://hyperledger.github.io/composer /latest/integrating/customizing-rest-server

这篇关于如何在Composer Rest Server中使用本地通行证进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 08:14