0
내 애플리케이션은 로그인해야 할 기준으로 사용자 정의 토큰을 가져옵니다. 토큰이 유효한지 확인하는 사용자 지정 응용 프로그램 코드가 있습니다.사용자 및 비밀번호없이 스프링 보안 인증 토큰을 수동으로 생성하십시오.
예컨대
public class CustomAuthenticationTokenProvider implements AuthenticationProvider {
public Authentication authenticate(final Authentication authentication) throws AuthenticationException {
// logic for validating the token. This gives a validated authentication
...
...
//Here first argument to constructor is principal and 2nd argument is //credentials.
CustomAuthenticationToken customAuthenticationToken = new CustomAuthenticationToken(authentication.getToken(), null);
return customAuthenticationToken;
}
}
나는 위의 검사를하고 잘 작동합니다.
쿼리 : 성공적인 인증 개체를 만들려면 자격 증명이 반드시 필요합니까? 그러한 접근에 관련된 위험이 있습니까?
예 사실입니다. 그러나이 경우 사용자 지정 코드를 사용하여 인증하는 키가 포함 된 요청 매개 변수를 얻고 있으며이 요청 매개 변수가 유효한 사용자 인 경우에만 성공적인 인증 토큰을 만듭니다. –
이 접근법에 심각한 문제가 있습니까? –