package com.example.MyFirstApp.config;
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.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.access.AccessDeniedHandler;
/**
* Created by Administrator on 17-7-14.
*/
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired
private AccessDeniedHandler accessDeniedHandler;
@Override
protected void configure(HttpSecurity http) throws Exception{
http.csrf().disable()
.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll()
.and()
.exceptionHandling().accessDeniedHandler(accessDeniedHandler);
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
auth.inMemoryAuthentication()
.withUser("user").password("password").roles("USER")
.and()
.withUser("admin").password("password").roles("ADMIN");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Gradle/Spring Boot/Thymeleaf (118个子文件)
gradlew.bat 2KB
fileSnapshots.bin 102KB
taskHistory.bin 26KB
fileHashes.bin 22KB
jvmClassSignatures.bin 20KB
annotation-processors.bin 19KB
last-build.bin 1B
built.bin 0B
SecurityConfig.class 5KB
AccessDeniedMyHandler.class 2KB
UserController.class 1KB
MyFirstAppApplication.class 735B
.gitignore 260B
build.gradle 837B
gradlew 5KB
login.html 1KB
login.html 1KB
home.html 725B
home.html 725B
admin.html 627B
admin.html 627B
user.html 626B
user.html 626B
403.html 456B
403.html 456B
footer.html 331B
footer.html 331B
index.html 270B
index.html 270B
MyFirstApp.iml 20KB
main.iml 424B
test.iml 423B
gradle-wrapper.jar 53KB
SecurityConfig.java 2KB
AccessDeniedMyHandler.java 1KB
UserController.java 846B
MyFirstAppApplicationTests.java 343B
MyFirstAppApplication.java 328B
fileContent.lock 38B
taskHistory.lock 38B
cache.properties.lock 2B
.name 10B
gradle-wrapper.properties 238B
cache.properties 53B
application.properties 36B
application.properties 36B
workspace.xml 76KB
misc.xml 10KB
uiDesigner.xml 9KB
compiler.xml 739B
Gradle__org_springframework_boot_spring_boot_test_autoconfigure_1_5_4_RELEASE.xml 718B
Gradle__org_springframework_boot_spring_boot_starter_thymeleaf_1_5_4_RELEASE.xml 713B
Gradle__org_springframework_boot_spring_boot_starter_websocket_1_5_4_RELEASE.xml 713B
Gradle__org_springframework_boot_spring_boot_starter_security_1_5_4_RELEASE.xml 707B
Gradle__org_springframework_boot_spring_boot_starter_logging_1_5_4_RELEASE.xml 703B
Gradle__org_springframework_boot_spring_boot_starter_tomcat_1_5_4_RELEASE.xml 698B
Gradle__org_springframework_boot_spring_boot_autoconfigure_1_5_4_RELEASE.xml 693B
Gradle__org_springframework_security_spring_security_config_4_2_3_RELEASE.xml 689B
Gradle__org_springframework_boot_spring_boot_starter_test_1_5_4_RELEASE.xml 688B
Gradle__org_springframework_boot_spring_boot_starter_web_1_5_4_RELEASE.xml 681B
Gradle__org_springframework_security_spring_security_core_4_2_3_RELEASE.xml 680B
Gradle__org_springframework_security_spring_security_web_4_2_3_RELEASE.xml 675B
Gradle__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 669B
Gradle__org_springframework_boot_spring_boot_starter_1_5_4_RELEASE.xml 663B
Gradle__org_springframework_boot_spring_boot_test_1_5_4_RELEASE.xml 648B
gradle.xml 647B
Gradle__nz_net_ultraq_thymeleaf_thymeleaf_layout_dialect_1_4_0.xml 644B
Gradle__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_15.xml 640B
Gradle__org_springframework_spring_expression_4_3_9_RELEASE.xml 638B
Gradle__org_springframework_spring_messaging_4_3_9_RELEASE.xml 633B
Gradle__org_springframework_spring_websocket_4_3_9_RELEASE.xml 633B
Gradle__com_fasterxml_jackson_core_jackson_annotations_2_8_0.xml 629B
Gradle__org_springframework_spring_context_4_3_9_RELEASE.xml 623B
Gradle__org_springframework_boot_spring_boot_1_5_4_RELEASE.xml 622B
Gradle__org_thymeleaf_thymeleaf_spring4_2_1_5_RELEASE.xml 620B
Gradle__org_hibernate_hibernate_validator_5_3_5_Final.xml 619B
Gradle__org_springframework_spring_webmvc_4_3_9_RELEASE.xml 618B
Gradle__org_apache_tomcat_embed_tomcat_embed_core_8_5_15.xml 615B
Gradle__com_fasterxml_jackson_core_jackson_databind_2_8_8.xml 614B
Gradle__org_springframework_spring_beans_4_3_9_RELEASE.xml 613B
Gradle__org_springframework_spring_test_4_3_9_RELEASE.xml 608B
Gradle__org_springframework_spring_core_4_3_9_RELEASE.xml 608B
Gradle__org_apache_tomcat_embed_tomcat_embed_el_8_5_15.xml 605B
Gradle__javax_validation_validation_api_1_1_0_Final.xml 604B
Gradle__org_springframework_spring_aop_4_3_9_RELEASE.xml 603B
Gradle__org_springframework_spring_web_4_3_9_RELEASE.xml 603B
Gradle__org_jboss_logging_jboss_logging_3_3_1_Final.xml 602B
Gradle__com_fasterxml_jackson_core_jackson_core_2_8_8.xml 594B
Gradle__org_thymeleaf_thymeleaf_2_1_5_RELEASE.xml 580B
Gradle__org_unbescape_unbescape_1_1_0_RELEASE.xml 580B
Gradle__ch_qos_logback_logback_classic_1_1_11.xml 577B
Gradle__org_slf4j_log4j_over_slf4j_1_7_25.xml 568B
Gradle__ch_qos_logback_logback_core_1_1_11.xml 562B
Gradle__org_hamcrest_hamcrest_library_1_3.xml 561B
Gradle__org_javassist_javassist_3_21_0_GA.xml 560B
Gradle__org_mockito_mockito_core_1_10_19.xml 559B
Gradle__com_jayway_jsonpath_json_path_2_2_0.xml 558B
Gradle__org_slf4j_jcl_over_slf4j_1_7_25.xml 558B
Gradle__net_minidev_accessors_smart_1_1.xml 554B
Gradle__org_skyscreamer_jsonassert_1_4_0.xml 551B
共 118 条
- 1
- 2
资源评论
- panthiechen2018-07-09还是可以学习学习的,谢谢
- 江南T雨2018-01-26还不错,谢谢分享!对于初学者非常实用。
- 屈想顺2018-07-06直接从官网上就能下载的案例
- ashiona2019-02-18正在尝试学习使用,谢谢分享
JuneHwa
- 粉丝: 38
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功