Skip to content
Snippets Groups Projects
Commit 71d57146 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

add option to disable the authentication for testing

parent d1f5bca4
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ portal-backend-build:
- docker run --rm -v $(pwd):/opt/portal/ -v $(pwd)/.m2:/root/.m2/ hbpmip/portal-backend-build
- echo 'Finished building portal-backend-build'
test:
- tests.sh
- ./tests.sh
portal-backend:
build: ./src/docker/run/Dockerfile
......@@ -21,4 +21,4 @@ portal-backend:
- rm -rf $(pwd)/src/docker/run/config/
- echo 'Finished building portal-backend'
test:
- tests.sh
\ No newline at end of file
- ./tests.sh
\ No newline at end of file
......@@ -48,3 +48,6 @@ workflow:
frontend:
redirect:
url: {{ .Env.FRONTEND_REDIRECT_URL }}
authentication:
enabled: {{ .Env.AUTHENTICATION }}
......@@ -48,3 +48,6 @@ workflow:
frontend:
redirect:
url: http://frontend/home
authentication:
enabled: 0
......@@ -32,6 +32,7 @@ services:
ML_URL: http://172.22.0.1:8087/mining
EXAREME_URL: http://hbps2.chuv.ch:9090/mining/query
FRONTEND_REDIRECT_URL: http://frontend/home
AUTHENTICATION: 0
portal-db:
container_name: portal-db
......
......@@ -82,20 +82,32 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Value("#{'${frontend.redirect.url:http://frontend/home}'}")
String frontendRedirect;
@Value("#{'${authentication.enabled:1}'}")
boolean authentication;
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http.addFilterBefore(new CORSFilter(), ChannelProcessingFilter.class);
http.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/frontend/**", "/webjars/**", "/v2/api-docs").permitAll()
.anyRequest().authenticated()
.and().exceptionHandling().authenticationEntryPoint(new CustomLoginUrlAuthenticationEntryPoint(loginUrl))
.and().logout().logoutSuccessUrl(loginUrl).permitAll()
.and().logout().logoutUrl(logoutUrl).permitAll()
.and().csrf().ignoringAntMatchers(logoutUrl).csrfTokenRepository(csrfTokenRepository())
.and().addFilterAfter(csrfHeaderFilter(), CsrfFilter.class)
.addFilterBefore(ssoFilter(), BasicAuthenticationFilter.class);
if(authentication) {
http.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/frontend/**", "/webjars/**", "/v2/api-docs").permitAll()
.anyRequest().authenticated()
.and().exceptionHandling().authenticationEntryPoint(new CustomLoginUrlAuthenticationEntryPoint(loginUrl))
.and().logout().logoutSuccessUrl(loginUrl).permitAll()
.and().logout().logoutUrl(logoutUrl).permitAll()
.and().csrf().ignoringAntMatchers(logoutUrl).csrfTokenRepository(csrfTokenRepository())
.and().addFilterAfter(csrfHeaderFilter(), CsrfFilter.class)
.addFilterBefore(ssoFilter(), BasicAuthenticationFilter.class);
}
else {
http.antMatcher("/**")
.authorizeRequests()
.antMatchers("/**").permitAll();
getUser();
}
}
private Filter ssoFilter() {
......@@ -173,11 +185,18 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
* @return
*/
public synchronized User getUser() {
User user = new User(getUserInfos());
User foundUser = userRepository.findOne(user.getUsername());
if(foundUser != null)
User user;
if(!authentication)
{
user.setAgreeNDA(foundUser.getAgreeNDA());
user = new User();
user.setUsername("TestUser");
}
else {
user = new User(getUserInfos());
User foundUser = userRepository.findOne(user.getUsername());
if (foundUser != null) {
user.setAgreeNDA(foundUser.getAgreeNDA());
}
}
userRepository.save(user);
return user;
......
#!/usr/bin/env bash
exit 0;
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment