Hyperledegr作曲家的LDAP护照策略

时间:2018-04-05 09:16:30

标签: github oauth-2.0 ldap passport.js hyperledger-composer

我一直在尝试使用LDAP护照策略在hyperledger composer rest服务器中进行身份验证。我正在使用以下配置ldap passport:

export COMPOSER_PROVIDERS='{
  "ldap": {
      "provider":"ldap",
      "authScheme":"ldap",
      "module":"passport-ldapauth",
      "authPath":"/auth/ldap",
      "successRedirect":"/",
      "failureRedirect":"/",
      "server":"{  
         "url":"ldap://localhost:389",
         "bindOn":"cn=admin,dc=example, dc=com",
         "bindCredentials":"*****",
         "searchBase":"ou=admin,dc=example,dc=com",
      }"
  }
}'

启动具有身份验证的composer-rest-server时显示错误

SyntaxError: Unexpected token 
 in JSON at position 210
    at JSON.parse (<anonymous>)
    at Promise.then (/home/mfgteg/.nvm/versions/node/v8.9.3/lib/node_modules/composer-rest-server/server/server.js:127:34)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

2 个答案:

答案 0 :(得分:0)

我的格式正确。感谢我在IBM site

上找到的链接

我使用了以下配置:

    export COMPOSER_PROVIDERS='{
  "ldap": {
      "provider": "ldap",
      "authScheme": "ldap",
      "module": "passport-ldapauth",
      "authPath": "/auth/ldap",
      "successRedirect": "/",
      "failureRedirect": "/",
      "server": {  
         "url": "ldap://localhost:389",
         "bindDn": "cn=admin,dc=example, dc=com",
         "bindCredentials": "*****",
         "searchBase": "ou=admin,dc=example,dc=com"
      }
  }
}'

但是我还没弄清楚在#34; callbackURL&#34;中提到了什么。

答案 1 :(得分:0)

使用下面提供的变量。只需根据您的配置更改successRedirectcredentials。同样,如果您正在其他计算机上运行客户端应用程序,则可能需要将localhost中的url更改为计算机IP地址。

注意:我已经在配置了开放LDAP的情况下对此进行了测试。

COMPOSER_PROVIDERS='{
    "ldap": {
   "provider": "ldap",
   "authScheme": "ldap",
   "module": "passport-ldapauth",
   "authPath": "/auth/ldap",
   "successRedirect": "Where you want to redirect",
   "failureRedirect": "/ldap",
   "session": true,
   "json": true,
   "LdapAttributeForLogin": "cn",
   "LdapAttributeForUsername": "cn",
    "server": {
    "url": "ldap://localhost:389",
    "bindDN": "cn=admin,dc=hsc,dc=com",
    "bindCredentials": "xxxxx", 
    "searchBase": "ou=users,dc=hsc,dc=com",
    "searchFilter": "(cn={{username}})"
  }
}
}'