Commit a654450a by Jan Hrabal

oa

parent 91c18743
......@@ -51,6 +51,18 @@
<artifactId>spring-boot-configuration-processor</artifactId>
</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>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
......
......@@ -20,6 +20,7 @@ import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
......@@ -40,10 +41,10 @@ import com.jh.boot.security.AuthService;
import com.jh.boot.security.PasswordUtils;
import com.jh.boot.security.model.AppUser;
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.NotFoundException;
import com.jh.boot.web.error.RestApiException;
import com.jh.boot.web.error.ValidationFailedException;
/**
* The Class AuthController.
......@@ -225,6 +226,16 @@ public class AuthApiController {
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?
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