I'm trying to connect my jhipster project with postgresql but I'm getting an error about the password.
Here is the error I'm getting
HHH000342: Could not obtain connection to query metadata : FATAL: password authentication failed for user "fabrice"
I have seen in pgadmin and the password is correct and so is the username .
My application-dev.yml
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:postgresql://localhost:5432/fabrice
username: fabrice
password: postgres
hikari:
poolName: Hikari
auto-commit: false
This is the postgres users photos:
I think this was what you wanted :
CREATE ROLE fabrice WITH
LOGIN
NOSUPERUSER
INHERIT
NOCREATEDB
NOCREATEROLE
NOREPLICATION
ENCRYPTED PASSWORD 'md576436d4007f2e5338a99e5a76181a7a4';
The problem was the port used by postgreSql it was 5433 instead of 5432 .So for the others persons you may check the port used by postgresql
Related
I was able to connect ldaps://ldap.google.com using the downloaded cert.
I'm trying to do the user authentication against it, always failed
My settings, we are using GSuite Business plus planning.
The connection url: ldaps://ldap.google.com
edit mode: read only
users DN: dc=xxxx,dc=xx (no filter applied)
search scope: subtree
Bind type:
When I set it to ‘none’ I get error: “error during sync of users” in server log:
error code 50: insufficient access rights
Uncaught server error: LDAP query failed.
When I enter a user:
User + #domain = LDAP: error 50 - Not authorized to authenticate password
User without #domain = error 49 - Incorrect password
User in DN = uid or cn=xxxx, ou=xxxx - error 50 - Not authorized to authenticate password
Anything I'm missing? or google ldap don't allow it?
I'm using Quarkus (2.7.3.Final) with Postgres (quarkus-jdbc-postgresql).
And I really like Quarkus' approach that if you configure no username, password and url for your datasource it will try to start a testcontainer and emulate the database, when you start the app in development mode.
So for example if you define this in your application.yml (or application.properties), Quarkus will start a Postgres testcontainer for you, when you start the app with ./mvnw clean quarkus:dev:
quarkus:
datasource:
username:
password:
db-kind: postgresql
jdbc:
driver: org.postgresql.Driver
url:
The log says "Dev Services for the default datasource (postgresql) started."
Pretty neat! :-)
However, what I really want is to define my real/productive database connection settings in my application.yml. And then overwrite them in the application-dev.yml, so that only in the development mode the testcontainer is started:
application.yml with PROD settings:
quarkus:
datasource:
username: myuser
password: mypassword
db-kind: postgresql
jdbc:
driver: org.postgresql.Driver
url: jdbc:postgresql://hostname:5432/mydb
application-dev.yml with DEV settings:
quarkus:
datasource:
username:
password:
jdbc:
url:
But overwriting the properties with null values doesn't work, when I start the app in development mode I get the error:
Datasource '<default>': Connection to hostname:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
The overwriting itself works, if I change my application-dev.yml to use an embedded H2 instead of the implicit testcontainer, the application starts:
application-dev.yml with H2 settings:
quarkus:
datasource:
username: sa
password: mypassword
db-kind: h2
jdbc:
driver: org.h2.Driver
url: jdbc:h2:mem:mydb;DB_CLOSE_DELAY=-1
So my question is: How can I overwrite my datasource configuration with null values, so that Quarkus uses testcontainers in dev mode?
And by the way, switching from a application.yml to Quarkus default application.properties unfortunately did not help.
Thanks a lot!
Just to complete this: Combining the previous answers and comments using the prod profile this my solution:
application.yml with DEV settings:
quarkus:
datasource:
username:
password:
db-kind: postgresql
jdbc:
driver: org.postgresql.Driver
url:
application-prod.yml with PROD settings:
quarkus:
datasource:
username: myuser
password: mypassword
jdbc:
url: jdbc:postgresql://hostname:5432/mydb
The application-dev.yml isn't needed this way. Thanks folks! :-)
Following Quarkus' official documentation,
If a profile does not define a value for a specific attribute, the
default (no profile) value is used
This behaviour will be useful in many cases, but in yours might lead to the inability to override properties once defined in the default profile back to their empty state.
I would suggest you to swap your profiles around i.e. treat the null-valued dev configuration as a default and provide meaningful non-null prod values in an overriding profile.
If you are worried that dev values might be used this way accidentally in prod environment, remember that Quarkus is going to use prod profile by default if not told otherwise.
I want to configure LDAP for my portal. I have added the connection details such as:
Connection
Base Provider URL : ldap://SBS.ecompany.local:300(example)
Base DN: ecompany.local
Principal : myldap username
Credentials: myldap password.
also did the following mappings:
Screen Name : sn
Email Address: mail
Password: userPassword
First Name: givenName
Middle Name
Last Name: sn
Full Name: givenName sn
Job Title : title
I checked for the connection, and I got the following message:
Liferay has successfully connected to the LDAP server.
When I checked for Test LDAP Users I got the following message:
Test LDAP Users A subset of users has been displayed for you to review.
No users were found.
(Might be because I did not provide LDATP admin uname and pwd)
But when I tried to login I was not able to login using the LDAP configuration.
And got this error:
09:38:33,808 ERROR [liferay/scheduler_dispatch-5][PortalLDAPImporterImpl:210] Error importing LDAP users and groups
javax.naming.directory.InvalidSearchFilterException: Empty filter; remaining name 'ecompany.local'
at com.sun.jndi.ldap.Filter.encodeFilterString(Filter.java:57)
at com.sun.jndi.ldap.LdapClient.search(LdapClient.java:548)
at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1985)
at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1844)
at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1769)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:392)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:358)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:341)
at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:267)
at com.liferay.portal.security.ldap.PortalLDAPUtil.searchLDAP(PortalLDAPUtil.java:820)
at com.liferay.portal.security.ldap.PortalLDAPUtil.getUsers(PortalLDAPUtil.java:617)
at com.liferay.portal.security.ldap.PortalLDAPUtil.getUsers(PortalLDAPUtil.java:652)
at com.liferay.portal.security.ldap.PortalLDAPImporterImpl.importFromLDAPByUser(PortalLDAPImporterImpl.java:695)
at com.liferay.portal.security.ldap.PortalLDAPImporterImpl.importFromLDAP(PortalLDAPImporterImpl.java:203)
at com.liferay.portal.security.ldap.PortalLDAPImporterImpl.importFromLDAP(PortalLDAPImporterImpl.java:139)
at com.liferay.portal.security.ldap.PortalLDAPImporterUtil.importFromLDAP(PortalLDAPImporterUtil.java:43)
at com.liferay.portlet.admin.messaging.LDAPImportMessageListener.doImportOnStartup(LDAPImportMessageListener.java:38)
at com.liferay.portlet.admin.messaging.LDAPImportMessageListener.doReceive(LDAPImportMessageListener.java:48)
at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:26)
at sun.reflect.GeneratedMethodAccessor405.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
at com.sun.proxy.$Proxy303.receive(Unknown Source)
at com.liferay.portal.kernel.scheduler.messaging.SchedulerEventMessageListenerWrapper.receive(SchedulerEventMessageListenerWrapper.java:77)
at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:72)
at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:69)
at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:682)
at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:593)
at java.lang.Thread.run(Thread.java:745)
The error is because of the DN. Can somebody help me solve this issue.
I got it working with an another issue. The problem was with the authentication search filter . I gave the format as :
Authentication Search Filter : Authentication Search Filter" as (mail=#email_address#). Actual format is Authentication Search Filter : (mail=#email_address#)
Next, the dn : format is dc=ecompany, dc=local.
The problem of ldap configuration was solved.
But when I changed the search filter from mail to screen name ie Authentication Search Filter : (sAMAccountName=#screen_name#) and also changed the How do users authenticate? to By screen name.
But I am not able to login using the ldap screen name and password. I checked the log files. I did not find any error. Please help .
I have set up an ldap authentication using the following configuration. I just need to user to authenticate to the LDAP data store, then have their session get an authentication token. From reading the docs, this is what I am thinking is supposed to happen:
applicationContextSecurity.xml
<ldap-server id="contextSource"
url="ldap://192.168.0.1:389/DC=cn,DC=bleum,DC=com"
manager-dn="cn=buddy,ou=Neil,OU=Development,OU=Micosoft,DC=cn,DC=Micosoft,DC=com"
manager-password="A,1234567890" />
<authentication-manager alias="authenticationManager" erase-credentials="true">
<!--<authentication-provider user-service-ref="securityManagerSupport"/> -->
<ldap-authentication-provider server-ref="contextSource" role-prefix="none" user-search-filter="(uid={0})"
user-search-base="ou=Neil,OU=Development,OU=Micosoft" user-context-mapper-ref="contextMapper">
</ldap-authentication-provider>
</authentication-manager>
<beans:bean id="contextMapper" class="com.micosoft.neil.security.UserDetailsContextMapperSupport"/>
Error:
[DEBUG,FilterBasedLdapUserSearch] Searching for user 'test', with user search [ searchFilter: '(samaccountname={0})', searchBase: 'dc=company,dc=com', scope: subtree, searchTimeLimit: 0, derefLinkFlag: false ]
[DEBUG,AbstractContextSource] Got Ldap context on server 'ldap://adapps.company.com:389/dc=company,dc=com'
[INFO,SpringSecurityLdapTemplate] Ignoring PartialResultException
[DEBUG,XmlWebApplicationContext] Publishing event in Root WebApplicationContext: org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent[source=org.springframework.security.authentication.UsernamePasswordAuthenticationToken#488b5f0b: Principal: test; Password: [PROTECTED]; Authenticated: false; Details: org.springframework.security.web.authentication.WebAuthenticationDetails#fffd148a: RemoteIpAddress: 127.0.0.1; SessionId: 0718B7EED3F930C63C03DA97C4344CBD; Not granted any authorities]
[DEBUG,UsernamePasswordAuthenticationFilter] Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials
[DEBUG,UsernamePasswordAuthenticationFilter] Updated SecurityContextHolder to contain null Authentication
[DEBUG,UsernamePasswordAuthenticationFilter] Delegating to authentication failure handlerorg.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler#395158
[DEBUG,TokenBasedRememberMeServices] Interactive login attempt was unsuccessful.
[DEBUG,TokenBasedRememberMeServices] Cancelling cookie
From the result, it looks like the password was incorrect, so if you were trying to enter an incorrect user / password, then yes, that is what is expected.
Really not sure what your question is though? Were you expecting something different? Did you pass the correct credentials?
I have the same error with pretty much the same configuration. I can't give you an answer yet (sorry!), but running a debugger through the Spring classes, it seems they're trying to compare the password the user entered as a string (and the debugger confirms it is the correct password) to a password retrieved from LDAP - which is null - which then fails.
I have set up an ldap authentication using the following configuration. I just need to user to authenticate to the LDAP data store, then have their session get an authentication token. From reading the docs, this is what I am thinking is supposed to happen:
Authenticate as the manager, find the users full dn based on search criteria
Attempt to bind as the user (using their full dn) and the provided password
The logs dont seem to give enough information as to why this is failing. It just says invalid credentials - when I know they are valid. My thoughts are one of the following is happening:
The users full DN is not being found, and they are just being authenticated with the username
It is trying to do a password compare, vs actually trying to bind to the directory
Configuration:
<ldap-server
url="ldap://adapps.company.com:389/dc=company,dc=com"
manager-dn="cn=fulluserdn,dc=company,dc=com"
manager-password="password"/>
<ldap-user-service user-search-base="" user-search-filter="(samaccountname={0})"/>
<authentication-manager>
<ldap-authentication-provider user-search-filter="(samaccountname={0})" user-search-base="dc=company,dc=com"/>
</authentication-manager>
Error logs:
[DEBUG,FilterBasedLdapUserSearch] Searching for user 'test', with user search [ searchFilter: '(samaccountname={0})', searchBase: 'dc=company,dc=com', scope: subtree, searchTimeLimit: 0, derefLinkFlag: false ]
[DEBUG,AbstractContextSource] Got Ldap context on server 'ldap://adapps.company.com:389/dc=company,dc=com'
[INFO,SpringSecurityLdapTemplate] Ignoring PartialResultException
[DEBUG,XmlWebApplicationContext] Publishing event in Root WebApplicationContext: org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent[source=org.springframework.security.authentication.UsernamePasswordAuthenticationToken#488b5f0b: Principal: test; Password: [PROTECTED]; Authenticated: false; Details: org.springframework.security.web.authentication.WebAuthenticationDetails#fffd148a: RemoteIpAddress: 127.0.0.1; SessionId: 0718B7EED3F930C63C03DA97C4344CBD; Not granted any authorities]
[DEBUG,UsernamePasswordAuthenticationFilter] Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials
[DEBUG,UsernamePasswordAuthenticationFilter] Updated SecurityContextHolder to contain null Authentication
[DEBUG,UsernamePasswordAuthenticationFilter] Delegating to authentication failure handlerorg.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler#395158
[DEBUG,TokenBasedRememberMeServices] Interactive login attempt was unsuccessful.
[DEBUG,TokenBasedRememberMeServices] Cancelling cookie
The problem was teat the LDAP server was running on a different port, but the normal port was still open.