Java/Spring Boot Security

Spring boot Security Authentication 데이터 내용

바리새인 2024. 8. 15. 20:02

입력

name: AA
password: DDD

소스

@Slf4j
public class CustomAuthenticationProvider extends DaoAuthenticationProvider {
    public Authentication authenticate(Authentication auth) throws AuthenticationException {
        log.debug(auth.getPrincipal().toString());
        log.debug(auth.toString());
        log.debug(auth.getName());
        log.debug(auth.getDetails().toString());
        log.debug(auth.getCredentials().toString());
        
        생략
	}
}

결과

AA
UsernamePasswordAuthenticationToken [Principal=AA, Credentials=[PROTECTED], Authenticated=false, Details=CustomWebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=304F976A0D0B9C983187CC049B190219], Granted Authorities=[]]
AA
CustomWebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=304F976A0D0B9C983187CC049B190219]
DDD

결론

auth.getPrincipal(): name
auth.getCredentials(): password