Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
bf0c8fc8
Commit
bf0c8fc8
authored
Sep 13, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove JDBC from secure-web sample
Fixes gh-1534
parent
9902f98a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
35 deletions
+6
-35
pom.xml
spring-boot-samples/spring-boot-sample-web-secure/pom.xml
+0
-8
SampleWebSecureApplication.java
...ain/java/sample/ui/secure/SampleWebSecureApplication.java
+6
-27
No files found.
spring-boot-samples/spring-boot-sample-web-secure/pom.xml
View file @
bf0c8fc8
...
...
@@ -23,18 +23,10 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-security
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-jdbc
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
...
...
spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/ui/secure/SampleWebSecureApplication.java
View file @
bf0c8fc8
...
...
@@ -19,18 +19,14 @@ package sample.ui.secure;
import
java.util.Date
;
import
java.util.Map
;
import
javax.sql.DataSource
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.security.SecurityProperties
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.co
re.Ordered
;
import
org.springframework.co
ntext.annotation.Configuration
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -65,16 +61,7 @@ public class SampleWebSecureApplication extends WebMvcConfigurerAdapter {
registry
.
addViewController
(
"/login"
).
setViewName
(
"login"
);
}
@Bean
public
ApplicationSecurity
applicationSecurity
()
{
return
new
ApplicationSecurity
();
}
@Bean
public
AuthenticationSecurity
authenticationSecurity
()
{
return
new
AuthenticationSecurity
();
}
@Configuration
@Order
(
SecurityProperties
.
ACCESS_OVERRIDE_ORDER
)
protected
static
class
ApplicationSecurity
extends
WebSecurityConfigurerAdapter
{
...
...
@@ -86,20 +73,12 @@ public class SampleWebSecureApplication extends WebMvcConfigurerAdapter {
http
.
authorizeRequests
().
anyRequest
().
fullyAuthenticated
().
and
().
formLogin
()
.
loginPage
(
"/login"
).
failureUrl
(
"/login?error"
).
permitAll
();
}
}
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
+
10
)
protected
static
class
AuthenticationSecurity
extends
GlobalAuthenticationConfigurerAdapter
{
@Autowired
private
DataSource
dataSource
;
@Override
public
void
init
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
jdbcAuthentication
().
dataSource
(
this
.
dataSource
).
withUser
(
"admin"
)
.
password
(
"admin"
).
roles
(
"ADMIN"
,
"USER"
).
and
().
withUser
(
"user"
)
.
password
(
"user"
).
roles
(
"USER"
);
public
void
configure
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
inMemoryAuthentication
().
withUser
(
"admin"
).
password
(
"admin"
)
.
roles
(
"ADMIN"
,
"USER"
).
and
().
withUser
(
"user"
).
password
(
"user"
)
.
roles
(
"USER"
);
}
}
...
...
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