Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Plan
Issues
27
Issue boards
Milestones
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
ARSnova
ARSnova Backend
Commits
a9bc07d5
Commit
a9bc07d5
authored
6 years ago
by
Daniel Gerhardt
Browse files
Options
Downloads
Plain Diff
Merge branch 'pac4j-3.x' into 'master'
Migrate Pac4j to version 3.4 See merge request
!111
parents
40fcc4ab
9216fadf
Branches
Branches containing commit
1 merge request
!111
Migrate Pac4j to version 3.4
Pipeline
#21011
passed with warnings with stages
Stage:
Stage:
Stage:
in 1 minute and 47 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pom.xml
+1
-1
1 addition, 1 deletion
pom.xml
src/main/java/de/thm/arsnova/security/pac4j/OauthCallbackFilter.java
+19
-9
19 additions, 9 deletions
...va/de/thm/arsnova/security/pac4j/OauthCallbackFilter.java
with
20 additions
and
10 deletions
pom.xml
+
1
−
1
View file @
a9bc07d5
...
...
@@ -257,7 +257,7 @@
<dependency>
<groupId>
org.pac4j
</groupId>
<artifactId>
pac4j-oauth
</artifactId>
<version>
2.3.1
</version>
<version>
3.4.0
</version>
</dependency>
<dependency>
<groupId>
com.corundumstudio.socketio
</groupId>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/thm/arsnova/security/pac4j/OauthCallbackFilter.java
+
19
−
9
View file @
a9bc07d5
...
...
@@ -20,6 +20,8 @@ package de.thm.arsnova.security.pac4j;
import
org.pac4j.core.client.Client
;
import
org.pac4j.core.client.Clients
;
import
org.pac4j.core.client.IndirectClient
;
import
org.pac4j.core.client.finder.ClientFinder
;
import
org.pac4j.core.client.finder.DefaultCallbackClientFinder
;
import
org.pac4j.core.config.Config
;
import
org.pac4j.core.context.J2EContext
;
import
org.pac4j.core.credentials.Credentials
;
...
...
@@ -38,6 +40,7 @@ import org.springframework.stereotype.Component;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Collections
;
import
java.util.List
;
/**
* Handles callback requests by login redirects from OAuth providers.
...
...
@@ -47,6 +50,7 @@ import java.util.Collections;
@Component
public
class
OauthCallbackFilter
extends
AbstractAuthenticationProcessingFilter
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OauthCallbackFilter
.
class
);
private
final
ClientFinder
clientFinder
=
new
DefaultCallbackClientFinder
();
private
Config
config
;
public
OauthCallbackFilter
(
Config
pac4jConfig
)
{
...
...
@@ -58,24 +62,30 @@ public class OauthCallbackFilter extends AbstractAuthenticationProcessingFilter
public
Authentication
attemptAuthentication
(
final
HttpServletRequest
httpServletRequest
,
final
HttpServletResponse
httpServletResponse
)
throws
AuthenticationException
{
CommonProfile
profile
=
retrieveProfile
(
new
J2EContext
(
httpServletRequest
,
httpServletResponse
));
final
String
clientName
=
httpServletRequest
.
getParameter
(
"client_name"
);
final
CommonProfile
profile
=
retrieveProfile
(
new
J2EContext
(
httpServletRequest
,
httpServletResponse
),
clientName
);
return
getAuthenticationManager
().
authenticate
(
new
OAuthToken
(
null
,
profile
,
Collections
.
emptyList
()));
}
private
CommonProfile
retrieveProfile
(
J2EContext
context
)
throws
AuthenticationServiceException
{
private
CommonProfile
retrieveProfile
(
final
J2EContext
context
,
final
String
clientName
)
throws
AuthenticationServiceException
{
/* Adapted from Pac4j: org.pac4j.core.engine.DefaultCallbackLogic.perform */
Clients
clients
=
config
.
getClients
();
final
Clients
clients
=
config
.
getClients
();
CommonHelper
.
assertNotNull
(
"clients"
,
clients
);
Client
client
=
clients
.
findClient
(
context
);
logger
.
debug
(
"client: {}"
,
client
);
CommonHelper
.
assertNotNull
(
"client"
,
client
);
CommonHelper
.
assertTrue
(
client
instanceof
IndirectClient
,
final
List
<
Client
>
foundClients
=
clientFinder
.
find
(
clients
,
context
,
clientName
);
CommonHelper
.
assertTrue
(
foundClients
!=
null
&&
foundClients
.
size
()
==
1
,
"unable to find one indirect client for the callback: check the callback URL for a client name parameter or suffix path"
+
" or ensure that your configuration defaults to one indirect client"
);
final
Client
foundClient
=
foundClients
.
get
(
0
);
logger
.
debug
(
"client: {}"
,
foundClient
);
CommonHelper
.
assertNotNull
(
"client"
,
foundClient
);
CommonHelper
.
assertTrue
(
foundClient
instanceof
IndirectClient
,
"only indirect clients are allowed on the callback url"
);
try
{
Credentials
credentials
=
c
lient
.
getCredentials
(
context
);
Credentials
credentials
=
foundC
lient
.
getCredentials
(
context
);
logger
.
debug
(
"credentials: {}"
,
credentials
);
CommonProfile
profile
=
c
lient
.
getUserProfile
(
credentials
,
context
);
CommonProfile
profile
=
foundC
lient
.
getUserProfile
(
credentials
,
context
);
logger
.
debug
(
"profile: {}"
,
profile
);
return
profile
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment