🌸🌸 pig token令牌解析器過程 🌸🌸
pig后端源碼
一、解析請求中的令牌值。
二、驗證令牌
- 內省并驗證給定的令牌,返回其屬性。
- 返回映射表示令牌有效。
/*** @author lengleng* @date 2019/2/1 擴展用戶信息*/
public class PigUser extends User implements OAuth2AuthenticatedPrincipal {private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;/*** 擴展屬性,方便存放oauth 上下文相關信息*/private final Map<String, Object> attributes = new HashMap<>();@Getter@JsonSerialize(using = ToStringSerializer.class)private final Long id;@Getter@JsonSerialize(using = ToStringSerializer.class)private final Long deptId;@Getterprivate final String phone;public PigUser(Long id, Long deptId, String username, String password, String phone, boolean enabled,boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked,Collection<? extends GrantedAuthority> authorities) {super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);this.id = id;this.deptId = deptId;this.phone = phone;}@Overridepublic Map<String, Object> getAttributes() {return this.attributes;}@Overridepublic String getName() {return this.getUsername();}
}
三、在此次調用中獲取信息
- 使用
SecurityUtils
獲取登錄信息