Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit e6d6b71

Browse files
authored
implemented ldap authentication (#11)
1 parent 59c5767 commit e6d6b71

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.3.1
2+
- Implemented ldap authentication functionality
3+
14
## 0.3.0
25
- Added functionality to load and parse the MINIFEST files to get the version
36
of the loaded messaging protocols.

build.gradle

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ buildscript {
55

66
dependencies {
77
classpath 'eu.appsatori:gradle-fatjar-plugin:0.3'
8+
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
89
}
910
}
1011

@@ -17,12 +18,19 @@ plugins{
1718

1819
apply plugin: 'java'
1920
apply plugin: 'eclipse'
21+
apply plugin: 'spring-boot'
2022

2123
jar {
2224
baseName = 'remrem-shared'
23-
version = '0.3.0'
25+
version = '0.3.1'
26+
}
27+
ext {
28+
springSecurityVersion = "1.4.1.RELEASE"
2429
}
2530

31+
bootRepackage{
32+
enabled = false
33+
}
2634
group 'com.ericsson.eiffel.remrem'
2735
version '1.0-SNAPSHOT'
2836

@@ -38,5 +46,7 @@ repositories {
3846

3947
dependencies {
4048
compile'com.google.code.gson:gson:2.6.2'
49+
compile("org.springframework.boot:spring-boot-starter-security:$springSecurityVersion")
50+
compile 'javax.servlet:javax.servlet-api:3.0.1'
4151
testCompile 'junit:junit:4.12'
4252
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.ericsson.eiffel.remrem.config;
2+
3+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.context.annotation.Profile;
6+
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
7+
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
8+
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
9+
10+
@Profile("!integration-test")
11+
@ConditionalOnProperty(value = "activedirectory.enabled", havingValue = "false")
12+
@Configuration
13+
@EnableWebSecurity
14+
public class DisabledSecurityConfig extends WebSecurityConfigurerAdapter {
15+
@Override
16+
protected void configure(HttpSecurity http) throws Exception {
17+
http.authorizeRequests().anyRequest().permitAll().and().csrf().disable();
18+
}
19+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.ericsson.eiffel.remrem.config;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.beans.factory.annotation.Value;
6+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.context.annotation.Profile;
9+
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
10+
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
11+
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
12+
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
13+
14+
@Profile("!integration-test")
15+
@Configuration
16+
@ConditionalOnProperty(value = "activedirectory.enabled")
17+
@EnableWebSecurity
18+
public class SecurityConfig extends WebSecurityConfigurerAdapter {
19+
20+
@Value("${activedirectory.enabled}")
21+
private boolean securityEnabled;
22+
23+
@Value("${activedirectory.ldapUrl}")
24+
private String ldapUrl;
25+
26+
@Value("${activedirectory.ldapPassword}")
27+
private String ldapPassword;
28+
29+
@Value("${activedirectory.managerDn}")
30+
private String managerDn;
31+
32+
@Value("${activedirectory.userSearchFilter}")
33+
private String userSearchFilter;
34+
35+
@Override
36+
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
37+
auth.ldapAuthentication().userSearchFilter(userSearchFilter).contextSource().managerDn(managerDn)
38+
.managerPassword(ldapPassword).url(ldapUrl);
39+
}
40+
41+
@Override
42+
protected void configure(HttpSecurity http) throws Exception {
43+
http.authorizeRequests().anyRequest().authenticated().and().httpBasic().and().csrf().disable();
44+
}
45+
}

0 commit comments

Comments
 (0)