Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
614a14e2
Commit
614a14e2
authored
Feb 14, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented simpe auth
parent
02eeeb97
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
70 deletions
+37
-70
SecurityConfig.java
...rc/main/java/nl/uva/sne/drip/api/conf/SecurityConfig.java
+6
-59
SpringSecurityInitializer.java
...a/nl/uva/sne/drip/api/conf/SpringSecurityInitializer.java
+22
-0
WebAppInitializer.java
...main/java/nl/uva/sne/drip/api/conf/WebAppInitializer.java
+1
-1
UserService.java
...rc/main/java/nl/uva/sne/drip/api/service/UserService.java
+8
-10
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/conf/SecurityConfig.java
View file @
614a14e2
...
...
@@ -15,77 +15,24 @@
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
conf
;
import
nl.uva.sne.drip.api.service.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
/**
*
* @author
S. Koulouzis
* @author
alogo
*/
@Configuration
@EnableWebSecurity
@ComponentScan
(
"nl.uva.sne.drip"
)
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
// @Autowired
// private UserService userService;
// @Autowired
// private AuthenticationFailureHandlerImpl authFailureHandler;
//
// @Autowired
// private AuthenticationSuccessHandlerImpl authSuccessHandler;
@Override
protected
void
configure
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
// auth
// .userDetailsService(userService).passwordEncoder(passwordEncoder());
auth
.
inMemoryAuthentication
().
withUser
(
"mkyong"
).
password
(
"123456"
).
roles
(
"USER"
);
auth
.
inMemoryAuthentication
().
withUser
(
"admin"
).
password
(
"123456"
).
roles
(
"ADMIN"
);
auth
.
inMemoryAuthentication
().
withUser
(
"dba"
).
password
(
"123456"
).
roles
(
"DBA"
);
@Autowired
public
void
configureGlobal
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
inMemoryAuthentication
()
.
withUser
(
"user"
).
password
(
"pwd"
).
roles
(
"USER"
);
}
// @Override
// protected void configure(HttpSecurity http) throws Exception {
// http
// .sessionManagement()
// .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
// .and()
// .exceptionHandling()
// .authenticationEntryPoint(authenticationEntryPoint())
// .accessDeniedHandler(accessDeniedHandler())
// .and();
// }
//
// @Bean(name = BeanIds.AUTHENTICATION_MANAGER)
// @Override
// public AuthenticationManager authenticationManagerBean() throws Exception {
// return super.authenticationManagerBean();
// }
////
// @Bean
// public PasswordEncoder passwordEncoder() {
// PasswordEncoder encoder = new BCryptPasswordEncoder();
// return encoder;
// }
////
// @Bean
// public AuthenticationEntryPoint authenticationEntryPoint() {
// AuthenticationEntryPoint authEp = new LoginUrlAuthenticationEntryPoint("/login.jsp");
// return authEp;
// }
//
// @Bean
// public AccessDeniedHandler accessDeniedHandler() {
// AccessDeniedHandler accessDenied = new org.springframework.security.web.access.AccessDeniedHandlerImpl();
// return accessDenied;
// }
}
drip-api/src/main/java/nl/uva/sne/drip/api/conf/
HelloWebSecurityConfiguration
.java
→
drip-api/src/main/java/nl/uva/sne/drip/api/conf/
SpringSecurityInitializer
.java
View file @
614a14e2
...
...
@@ -15,21 +15,8 @@
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
conf
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer
;
@Configuration
@EnableWebSecurity
public
class
HelloWebSecurityConfiguration
extends
WebSecurityConfigurerAdapter
{
public
class
SpringSecurityInitializer
extends
AbstractSecurityWebApplicationInitializer
{
@Autowired
public
void
configureGlobal
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
inMemoryAuthentication
()
.
withUser
(
"user"
).
password
(
"password"
).
roles
(
"USER"
);
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/conf/WebAppInitializer.java
View file @
614a14e2
...
...
@@ -27,7 +27,7 @@ public class WebAppInitializer implements WebApplicationInitializer {
AnnotationConfigWebApplicationContext
ctx
=
new
AnnotationConfigWebApplicationContext
();
ctx
.
register
(
MultipartConfig
.
class
);
ctx
.
register
(
MongoConfig
.
class
);
//
ctx.register(SecurityConfig.class);
ctx
.
register
(
SecurityConfig
.
class
);
ctx
.
setServletContext
(
servletContext
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/service/UserService.java
View file @
614a14e2
...
...
@@ -26,15 +26,13 @@ import org.springframework.stereotype.Service;
*
* @author S. Koulouzis
*/
@Service
public
class
UserService
implements
UserDetailsService
{
@Autowired
UserDao
dao
;
@Override
public
UserDetails
loadUserByUsername
(
String
string
)
throws
UsernameNotFoundException
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
//To change body of generated methods, choose Tools | Templates.
}
//@Service
public
class
UserService
{
// implements UserDetailsService {
// @Autowired
// UserDao dao;
// @Override
// public UserDetails loadUserByUsername(String string) throws UsernameNotFoundException {
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
// }
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment