2018-11-15 11:24:18 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package ch.ethz.seb.sebserver;
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
|
|
|
|
|
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
|
|
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
|
|
|
|
|
|
|
/** This is the overall seb-server Spring web-configuration that is loaded for all profiles.
|
|
|
|
* Defines some overall web-security beans needed on both -- web-service and web-gui -- profiles */
|
|
|
|
@Configuration
|
|
|
|
@WebServiceProfile
|
|
|
|
@GuiProfile
|
2018-11-22 10:39:18 +01:00
|
|
|
public class WebSecurityConfig {
|
2018-11-15 11:24:18 +01:00
|
|
|
|
|
|
|
/** Spring bean name of user password encoder */
|
|
|
|
public static final String USER_PASSWORD_ENCODER_BEAN_NAME = "userPasswordEncoder";
|
|
|
|
/** Spring bean name of client (application) password encoder */
|
|
|
|
public static final String CLIENT_PASSWORD_ENCODER_BEAN_NAME = "clientPasswordEncoder";
|
|
|
|
|
|
|
|
/** Password encoder used for user passwords (stronger protection) */
|
|
|
|
@Bean(USER_PASSWORD_ENCODER_BEAN_NAME)
|
|
|
|
public PasswordEncoder userPasswordEncoder() {
|
|
|
|
return new BCryptPasswordEncoder(8);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Password encode used for client (application) passwords */
|
|
|
|
@Bean(CLIENT_PASSWORD_ENCODER_BEAN_NAME)
|
|
|
|
public PasswordEncoder clientPasswordEncoder() {
|
|
|
|
return new BCryptPasswordEncoder(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|