인터넷에서 spring security를 검색하면 한글 자료는 대부분 xml 설정으로 되어있다.

먼저 web.xml에 DelegateFilterProxy를 설정하는 것부터 나온다.

그리고 나머지 설정을 외우거나 복붙해서 만든다.

반면 java 설정은 자동완성과 클래스를 들여다 보기때문에 공부하는데 더 좋다.

설정도 web.xml에 필터를 등록할 필요 없다.


먼저 필요한 dependency 설정을 한다.
        <dependency>
  		<groupId>org.springframework.security</groupId>
  		<artifactId>spring-security-web</artifactId>
  		<version>5.0.0.RELEASE</version>
  	</dependency>
  	<dependency>
  		<groupId>org.springframework.security</groupId>
  		<artifactId>spring-security-config</artifactId>
  		<version>5.0.0.RELEASE</version>
  	</dependency>
  	<dependency>
  		<groupId>org.springframework.security</groupId>
  		<artifactId>spring-security-taglibs</artifactId>
  		<version>5.0.0.RELEASE</version>
  	</dependency>
자바 설정은 다음 클래스로 시작한다.

@Configuration

@EnableWebSecurity

public class CustomSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter


클래스로 시작하면 된다.


클래스 멤버는 다음과 같다.


아이디와 패스워드 권한을 설정한다. 시작은 인메모리 방식으로~~
    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
          .withUser("user1").password("user1Pass")
          .authorities("ROLE_USER");
    }

    }

경로에 권한 설정과 로그인 페이지 설정을 한다. 로그인 페이지 설정을 안하면 브라우저 prompt로 인증을 요구한다. 로그인 페이지 url을 설정안하면 디폴트 로그인 페이지가 나온다.
        @Override
	protected void configure(HttpSecurity http) throws Exception {
		
		logger.info("http: "+http);
		
		http.httpBasic(); 
		http.authorizeRequests().antMatchers("/main/**").hasRole("USER");		
		http.formLogin().loginPage("/login")
			.usernameParameter("username").passwordParameter("password")
			.permitAll()
			.and();
	}
spring-security 시작은 단순하다.


Invalid character found in method name. HTTP method names must be tokens


https 요청 처리 안되있는데 요청이 들어올 경우


프로토콜을 잘 보길

'스프링(Spring)' 카테고리의 다른 글

spring security#2 DB를 통한 인증  (0) 2018.01.17
spring-security#1 시작하기  (0) 2018.01.16
Spring + Mysql + MyBatis  (0) 2017.10.29
스프링 설정#4 예외처리 하기  (0) 2017.10.06
스프링설정 #3 Transaction설정  (0) 2017.10.06

pseudo code는 dom요소가 아니기때문에 event를 붙일 수가 없다.

하지만 프로그래밍으로 안되는 건 없다.

:after 는 해당 태그의 돔으로 인식된다.

하지만 해당 태그의 width 밖에 있다.

offset.x로 포인터 좌표를 찾을 수 있다.


span = document.querySelector('span');
span.addEventListener('click', function (e) {

    if (e.offsetX > span.offsetWidth) {
        // pseudo event
    } else {
        // orginal dom event
    }
});

멋진 아이디어다.

'javascript' 카테고리의 다른 글

let의 필요성  (0) 2018.03.20
async function 과 await  (0) 2018.03.10
ajax의 자동 encoding  (0) 2017.12.28
mousewheel 이벤트 버그  (0) 2017.12.28
ie, chrom] new Date 관련  (0) 2017.12.27

+ Recent posts