Commit a654450a by Jan Hrabal

oa

parent 91c18743
...@@ -51,6 +51,18 @@ ...@@ -51,6 +51,18 @@
<artifactId>spring-boot-configuration-processor</artifactId> <artifactId>spring-boot-configuration-processor</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.4.0.RELEASE</version>
</dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
......
...@@ -20,6 +20,7 @@ import org.springframework.security.authentication.BadCredentialsException; ...@@ -20,6 +20,7 @@ import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
...@@ -40,10 +41,10 @@ import com.jh.boot.security.AuthService; ...@@ -40,10 +41,10 @@ import com.jh.boot.security.AuthService;
import com.jh.boot.security.PasswordUtils; import com.jh.boot.security.PasswordUtils;
import com.jh.boot.security.model.AppUser; import com.jh.boot.security.model.AppUser;
import com.jh.boot.utils.Utils; import com.jh.boot.utils.Utils;
import com.jh.boot.web.error.ValidationFailedException;
import com.jh.boot.web.error.ErrorMessage; import com.jh.boot.web.error.ErrorMessage;
import com.jh.boot.web.error.NotFoundException; import com.jh.boot.web.error.NotFoundException;
import com.jh.boot.web.error.RestApiException; import com.jh.boot.web.error.RestApiException;
import com.jh.boot.web.error.ValidationFailedException;
/** /**
* The Class AuthController. * The Class AuthController.
...@@ -225,6 +226,16 @@ public class AuthApiController { ...@@ -225,6 +226,16 @@ public class AuthApiController {
return ((AppUserAuthentication) auth).getUser(); return ((AppUserAuthentication) auth).getUser();
} }
//TODO oauth2 token
if (auth instanceof OAuth2Authentication) {
OAuth2Authentication oauth = (OAuth2Authentication) auth;
String username = String.valueOf(oauth.getPrincipal());
System.out.println(username);
AppUser user = new AppUser();
user.setLogin(username);
return user;
}
//TODO other auth types? //TODO other auth types?
return null; return null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment