Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jh-boot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jan Hrabal
jh-boot
Commits
a654450a
Commit
a654450a
authored
Mar 16, 2020
by
Jan Hrabal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oa
parent
91c18743
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
pom.xml
pom.xml
+12
-0
AuthApiController.java
...main/java/com/jh/boot/security/api/AuthApiController.java
+12
-1
No files found.
pom.xml
View file @
a654450a
...
...
@@ -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>
...
...
src/main/java/com/jh/boot/security/api/AuthApiController.java
View file @
a654450a
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment