Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenID Connect with OpenLDAP #1582

Open
pipa1985 opened this issue Sep 5, 2022 · 4 comments
Open

OpenID Connect with OpenLDAP #1582

pipa1985 opened this issue Sep 5, 2022 · 4 comments

Comments

@pipa1985
Copy link

pipa1985 commented Sep 5, 2022

Hello,
I was able to install OpenID Connect by following the instructions given here leaving everything on default. Now I want to use an LDAP directory so here is how I intend to proceed. Please tell me if this is correct. Personally, I'm thinking of installing OpenLDAP first, then downloading ldap-openid-connect-server and modifying the user-context.xml file to point to my LDAP server, and finally use the commands mvn package and mvn jetty:run-war to build and deploy the server. Is it correct ? I'm really not an expert.

@pipa1985
Copy link
Author

pipa1985 commented Sep 7, 2022

Hello,
I installed ldap overlay and the execution of the two commands mvn package and mvn jetty:run-war did not generate any error. But when I try to access the link: http://localhost:8080/ldap-openid-connect-server/ It shows a 404 error:

**Error 404 Not Found

There was an error processing your request.

Not Found**

Knowing that OpenLDAP and OpenID Connect are installed on the same machine
Do you have an idea of what it could be, I will really appreciate your help because I am completely lost.
I am using Jetty

@pipa1985
Copy link
Author

pipa1985 commented Sep 8, 2022

This link works with tomcat, however, when I try to login with an LDAP account It shows me the following message:
The system was unable to log you in. Please try again.
The only error in catalina.out is the following:
INFO : org.mitre.openid.connect.config.JsonMessageSource - No locale loaded, trying to load from ServletContext resource [/resources/js/locale/fr/messages.json]
[2022-09-08 09:25:33] [info] ERROR: org.mitre.openid.connect.config.JsonMessageSource - Unable to load locale
[2022-09-08 09:25:33] [info] java.io.FileNotFoundException: Could not open ServletContext resource [/resources/js/locale/fr/messages.json]

Maybe I misconfigured the user-context.XML file, can you please check:
**

    <security:ldap-server url="ldap://192.168.43.118:389/dc=my-university,dc=dz" />

    <bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
            <constructor-arg>
                    <bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
                            <constructor-arg ref="contextSource" />
                            <property name="userDnPatterns">
                                    <list>
                                            <value>uid={0}</value>
                                    </list>
                            </property>
                    </bean>
            </constructor-arg>
            <constructor-arg>
                    <bean class="edu.mit.kit.userdetails.MappedLdapAuthoritiesPopulator">
                            <property name="admins">
                                    <set>
                                            <!-- list admin usernames here -->
                                    </set>
                            </property>
                    </bean>
            </constructor-arg>
    </bean>

    <bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
            <property name="url" value="ldap://192.168.43.118:389" />
            <property name="base" value="dc=my-university,dc=dz" />
    </bean>

    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
            <constructor-arg name="contextSource" ref="contextSource" />
    </bean>

    <bean id="ldapUserInfoRepository" primary="true" class="edu.mit.kit.repository.impl.LdapUserInfoRepository">
            <property name="ldapTemplate" ref="ldapTemplate" />
    </bean>

    <!-- end LDAP -->**

@pipa1985
Copy link
Author

pipa1985 commented Sep 9, 2022

Can the LDAP server and OpenID Connect be in the same server

@pipa1985
Copy link
Author

pipa1985 commented Sep 16, 2022

Actually there was a problem in the LDAP schema.
The problem is solved. Bellow my configuration.
Now I have a problem to connect OpenID Connect with Moodle, but I prefer to open a new post

<security:ldap-server url="ldap://192.168.43.118:389/dc=my-university,dc=dz" />

<bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
        <constructor-arg>
                <bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
                        <constructor-arg ref="contextSource" />
                        <property name="userDnPatterns">
                                <list>
                                        <value>uid={0},ou=people</value>
                                </list>
                        </property>
                </bean>
        </constructor-arg>
        <constructor-arg>
                <bean class="edu.mit.kit.userdetails.MappedLdapAuthoritiesPopulator">
                        <property name="admins">
                                <set>
                                        <!-- list admin usernames here -->
                                         <value>me</value>
                                </set>
                        </property>
                </bean>
        </constructor-arg>
</bean>

<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
        <property name="url" value="ldap://192.168.43.118:389" />
        <property name="base" value="dc=my-university,dc=dz" />
</bean>

<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
        <constructor-arg name="contextSource" ref="contextSource" />
</bean>

<bean id="ldapUserInfoRepository" primary="true" class="edu.mit.kit.repository.impl.LdapUserInfoRepository">
        <property name="ldapTemplate" ref="ldapTemplate" />
</bean>

<!-- end LDAP -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant