oauth change
This commit is contained in:
@@ -20,19 +20,21 @@ public class AuthorizationServerApplication implements CommandLineRunner {
|
||||
}
|
||||
|
||||
// TODO 삭제 - 테스트로 유저를 넣어서 확인하는 코드입니다.
|
||||
// @Autowired
|
||||
// private UserRepository repository;
|
||||
// @Autowired private PasswordEncoder passwordEncoder;
|
||||
@Autowired
|
||||
private UserRepository repository;
|
||||
@Autowired private PasswordEncoder passwordEncoder;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
|
||||
// User user = new User();
|
||||
// user.setUsername("4@4.com");
|
||||
// user.setPassword(passwordEncoder.encode("password"));
|
||||
// user.setRole("USER_ADMIN");
|
||||
////
|
||||
// repository.save(user);
|
||||
User user = new User();
|
||||
user.setUsername("1@uengine.org");
|
||||
user.setPassword(passwordEncoder.encode("1"));
|
||||
user.setNickName("유엔진");
|
||||
user.setAddress("서울시");
|
||||
user.setRole("USER_ADMIN");
|
||||
//
|
||||
repository.save(user);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -166,6 +166,10 @@ public class OAuth2AuthorizationServerConfig extends AuthorizationServerConfigur
|
||||
if(authentication.isAuthenticated()) {
|
||||
Map<String, Object> additionalInfo = new HashMap<>();
|
||||
additionalInfo.put("company", "Uengine");
|
||||
|
||||
User user = (User)authentication.getPrincipal();
|
||||
additionalInfo.put("nickname", user.getNickName());
|
||||
additionalInfo.put("address", user.getAddress());
|
||||
// String clientId = authentication.getOAuth2Request().getClientId();
|
||||
// logger.debug("client ID : " + clientId);
|
||||
|
||||
|
||||
@@ -11,38 +11,119 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class User implements UserDetails{
|
||||
|
||||
@Id
|
||||
@Getter@Setter
|
||||
private String username;
|
||||
|
||||
@Column(length=400)
|
||||
@Getter@Setter
|
||||
private String password;
|
||||
|
||||
@Column
|
||||
@Getter@Setter
|
||||
private String role;
|
||||
|
||||
|
||||
// additional
|
||||
private String nickName;
|
||||
private String address;
|
||||
|
||||
@Transient
|
||||
@Getter@Setter
|
||||
private Collection<? extends GrantedAuthority> authorities;
|
||||
|
||||
@Getter@Setter
|
||||
private boolean accountNonExpired = true;
|
||||
|
||||
@Getter@Setter
|
||||
private boolean accountNonLocked = true;
|
||||
|
||||
@Getter@Setter
|
||||
private boolean credentialsNonExpired = true;
|
||||
|
||||
@Getter@Setter
|
||||
private boolean enabled = true;
|
||||
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return authorities;
|
||||
}
|
||||
|
||||
public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
|
||||
this.authorities = authorities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return accountNonExpired;
|
||||
}
|
||||
|
||||
public void setAccountNonExpired(boolean accountNonExpired) {
|
||||
this.accountNonExpired = accountNonExpired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return accountNonLocked;
|
||||
}
|
||||
|
||||
public void setAccountNonLocked(boolean accountNonLocked) {
|
||||
this.accountNonLocked = accountNonLocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return credentialsNonExpired;
|
||||
}
|
||||
|
||||
public void setCredentialsNonExpired(boolean credentialsNonExpired) {
|
||||
this.credentialsNonExpired = credentialsNonExpired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user