spring security 1

김가빈·2023년 7월 27일
0

springsecurity

목록 보기
2/23
post-thumbnail

Basic Spring Security Example

  • generate spring boot project
  • never choose java version under 17
    • spring security 6 and spring boot 3 need over java 17 version
  • create package and class
package com.eazybytes.springsecuritybasic.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WelcomeController {
	
	@GetMapping("/welcome")
	public String sayWelcome() {
		return "Welcome to Spring Application with out Security";
	}
}
package com.eazybytes.springsecuritybasic;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan("com.eazybytes.springsecuritybasic.controller") // optional
public class SpringsecuritybasicApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringsecuritybasicApplication.class, args);
	}

}
  • then you can see this login page whatever you enter url
  • id = user password = is in the console
  • and then you can enter to url

setting id and pass word

  • you can setting all properties in application.properties when you use spring security
  • setting security id & password like this
  • but this program you can just enter one id and password
  • we need another users can enter to our application, and they need to have other athentication
profile
신입 웹개발자입니다.

1개의 댓글

comment-user-thumbnail
2023년 7월 27일

좋은 정보 감사합니다

답글 달기