Skip to Content
Suffering builds character

3.인증 객체

인증 처리 수행 시 사용되는 객체, 현재 인증된 사용자의 자격 증명 정보를 담고 있는 인터페이스

Authentication.java
public interface Authentication extends Principal, Serializable { Collection<? extends GrantedAuthority> getAuthorities(); Object getCredentials(); Object getPrincipal(); // ... 생략 }

따라서 이러한 Authencation 객체는 다음과 같은 자격 증명 정보들로 구성됨

💡
Tip

자격 증명 정보

  1. 접근 주체, Principle
  2. 암호, Credentials
  3. 권한, Authorities

1-1. Principal, 접근 주체

애플리케이션의 서비스(resource)에 접근하는 사용자를 주체(Principle)라고 함

java.security 패키지의 Principal 인터페이스가 같은 개념을 나타내며, 스프링 시큐리티의 Authentication 인터페이스는 이 인터페이스를 확장한 인터페이스

Username/password 기반 인증 맥락에서 실제 구현체는 주로 UserDetails 객체가 활용됨

1-2. Credentials, 비밀 정보

주로 비밀번호를 의미하며, 대부분의 상황에서 사용자가 인증된 후에 비밀번호가 유출되지 않도록 하기 위해 이 비밀번호가 유지되지 않고 가려지거나(Masking) 지워짐

1-3. Authorities, 권한

해당 접근 주체(Principal)가 가지고 있는 권한 정보로, 컬렉션(Collection) 타입의 형태로 가지고 있음

실제 구현체로는 GrantedAuthority가 활용됨

2. GrantedAuthority

GrantedAuthority는 사용자에게 부여된 하나의 권한 정보를 가진 인터페이스 사용자의 권한을 확인할 때 사용됨

GrantedAuthority.java
public interface GrantedAuthority extends Serializable { String getAuthority(); }
Last updated on