GET /api/account returns error when LDAP authentic

2019-08-17 07:07发布

Overview of the issue

GET /api/account return 500 error when we have ldap integration in jhipster uaa, the user is present in ldap directory not in the uaa DB, therefore it return 500 error, no user found

Motivation for or Use Case

It is a doubt, so my question is should we add the user in DB after successful authentication from Ldap or do I need to update the API according to my requirement, which will be the solution.

Reproduce the error

Add embedded ldap configuration in uaa:

@override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
if (enabled.equalsIgnoreCase("true")) {
ContextSourceBuilder csb = auth.ldapAuthentication().userSearchBase(userSearchBase).userSearchFilter(userSearchFilter).groupSearchBase(groupSearchBase).groupSearchFilter(groupSearchFilter).contextSource();
if (StringUtils.isNotEmpty(root)) {
csb.root(root);
}
if (StringUtils.isNotEmpty(ldapUrl)) {
csb.url(ldapUrl);
}
if (StringUtils.isNotEmpty(ldifFilePath)) {
csb.ldif(ldifFilePath);
}
if (StringUtils.isNotEmpty(manager)) {
csb.managerDn(manager);
}
if (StringUtils.isNotEmpty(managerPassword)) {
csb.managerPassword(managerPassword);
}
} else {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
}

When user logs in, the user is verified from ldap directory and after login GET /api/account is trigerred for some information. The user is not present in the uaa app DB, therefore it returns error.

Related issues

Suggest a Fix

JHipster Version(s)

4.3.0

JHipster configuration

Welcome to the JHipster Information Sub-Generator

JHipster Version(s)

/home/varunn/git/etuaa `-- generator-jhipster@4.3.0

JHipster configuration, a .yo-rc.json file generated in the root folder

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.abc.uaa",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "4.3.0",
    "baseName": "uaa",
    "packageName": "com.abc.uaa",
    "packageFolder": "com/abc/uaa",
    "serverPort": "9999",
    "authenticationType": "uaa",
    "hibernateCache": "hazelcast",
    "clusteredHttpSession": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableTranslation": true,
    "applicationType": "uaa",
    "testFrameworks": [
      "gatling",
      "cucumber"
    ],
    "jhiPrefix": "jhi",
    "skipClient": true,
    "nativeLanguage": "en",
    "languages": [
      "en",
      "fr",
      "es"
    ],
    "clientPackageManager": "yarn"
  }
}

Entity configuration(s) entityName.json files generated in the .jhipster directory

ls: no such file or directory: .jhipster/*.json

Browsers and Operating System

java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

git version 2.7.4

node: v8.4.0

npm: 5.3.0

yeoman: 1.8.5

yarn: 0.24.6

Docker version 17.03.1-ce, build c6d412e

docker-compose version 1.14.0, build c7bdf9e

Entity configuration(s) entityName.json files generated in the .jhipster directory

Browsers and Operating System

Chrome and

Ubuntu 16.04

0条回答
登录 后发表回答