Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
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
Paul-Christian Volkmer
ARSnova Backend
Commits
5eeb0cec
Commit
5eeb0cec
authored
8 years ago
by
Daniel Gerhardt
Browse files
Options
Downloads
Patches
Plain Diff
Block auth requests for disabled auth services
parent
2e2a4eb9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/thm/arsnova/controller/LoginController.java
+11
-7
11 additions, 7 deletions
src/main/java/de/thm/arsnova/controller/LoginController.java
with
11 additions
and
7 deletions
src/main/java/de/thm/arsnova/controller/LoginController.java
+
11
−
7
View file @
5eeb0cec
...
@@ -162,7 +162,7 @@ public class LoginController extends AbstractController {
...
@@ -162,7 +162,7 @@ public class LoginController extends AbstractController {
userSessionService
.
setRole
(
role
);
userSessionService
.
setRole
(
role
);
if
(
"arsnova"
.
equals
(
type
))
{
if
(
dbAuthEnabled
&&
"arsnova"
.
equals
(
type
))
{
Authentication
authRequest
=
new
UsernamePasswordAuthenticationToken
(
username
,
password
);
Authentication
authRequest
=
new
UsernamePasswordAuthenticationToken
(
username
,
password
);
try
{
try
{
Authentication
auth
=
daoProvider
.
authenticate
(
authRequest
);
Authentication
auth
=
daoProvider
.
authenticate
(
authRequest
);
...
@@ -180,7 +180,7 @@ public class LoginController extends AbstractController {
...
@@ -180,7 +180,7 @@ public class LoginController extends AbstractController {
userService
.
increaseFailedLoginCount
(
addr
);
userService
.
increaseFailedLoginCount
(
addr
);
response
.
setStatus
(
HttpStatus
.
UNAUTHORIZED
.
value
());
response
.
setStatus
(
HttpStatus
.
UNAUTHORIZED
.
value
());
}
else
if
(
"ldap"
.
equals
(
type
))
{
}
else
if
(
ldapEnabled
&&
"ldap"
.
equals
(
type
))
{
if
(!
""
.
equals
(
username
)
&&
!
""
.
equals
(
password
))
{
if
(!
""
.
equals
(
username
)
&&
!
""
.
equals
(
password
))
{
org
.
springframework
.
security
.
core
.
userdetails
.
User
user
=
org
.
springframework
.
security
.
core
.
userdetails
.
User
user
=
new
org
.
springframework
.
security
.
core
.
userdetails
.
User
(
new
org
.
springframework
.
security
.
core
.
userdetails
.
User
(
...
@@ -206,7 +206,7 @@ public class LoginController extends AbstractController {
...
@@ -206,7 +206,7 @@ public class LoginController extends AbstractController {
userService
.
increaseFailedLoginCount
(
addr
);
userService
.
increaseFailedLoginCount
(
addr
);
response
.
setStatus
(
HttpStatus
.
UNAUTHORIZED
.
value
());
response
.
setStatus
(
HttpStatus
.
UNAUTHORIZED
.
value
());
}
}
}
else
if
(
"guest"
.
equals
(
type
))
{
}
else
if
(
guestEnabled
&&
"guest"
.
equals
(
type
))
{
List
<
GrantedAuthority
>
authorities
=
new
ArrayList
<
GrantedAuthority
>();
List
<
GrantedAuthority
>
authorities
=
new
ArrayList
<
GrantedAuthority
>();
authorities
.
add
(
new
SimpleGrantedAuthority
(
"ROLE_GUEST"
));
authorities
.
add
(
new
SimpleGrantedAuthority
(
"ROLE_GUEST"
));
if
(
username
==
null
||
!
username
.
startsWith
(
"Guest"
)
||
username
.
length
()
!=
MAX_USERNAME_LENGTH
)
{
if
(
username
==
null
||
!
username
.
startsWith
(
"Guest"
)
||
username
.
length
()
!=
MAX_USERNAME_LENGTH
)
{
...
@@ -221,6 +221,8 @@ public class LoginController extends AbstractController {
...
@@ -221,6 +221,8 @@ public class LoginController extends AbstractController {
SecurityContextHolder
.
getContext
().
setAuthentication
(
token
);
SecurityContextHolder
.
getContext
().
setAuthentication
(
token
);
request
.
getSession
(
true
).
setAttribute
(
HttpSessionSecurityContextRepository
.
SPRING_SECURITY_CONTEXT_KEY
,
request
.
getSession
(
true
).
setAttribute
(
HttpSessionSecurityContextRepository
.
SPRING_SECURITY_CONTEXT_KEY
,
SecurityContextHolder
.
getContext
());
SecurityContextHolder
.
getContext
());
}
else
{
response
.
setStatus
(
HttpStatus
.
BAD_REQUEST
.
value
());
}
}
}
}
...
@@ -262,19 +264,21 @@ public class LoginController extends AbstractController {
...
@@ -262,19 +264,21 @@ public class LoginController extends AbstractController {
request
.
getSession
().
setAttribute
(
"ars-login-success-url"
,
serverUrl
+
successUrl
);
request
.
getSession
().
setAttribute
(
"ars-login-success-url"
,
serverUrl
+
successUrl
);
request
.
getSession
().
setAttribute
(
"ars-login-failure-url"
,
serverUrl
+
failureUrl
);
request
.
getSession
().
setAttribute
(
"ars-login-failure-url"
,
serverUrl
+
failureUrl
);
if
(
"cas"
.
equals
(
type
))
{
if
(
casEnabled
&&
"cas"
.
equals
(
type
))
{
casEntryPoint
.
commence
(
request
,
response
,
null
);
casEntryPoint
.
commence
(
request
,
response
,
null
);
}
else
if
(
"twitter"
.
equals
(
type
))
{
}
else
if
(
twitterEnabled
&&
"twitter"
.
equals
(
type
))
{
final
String
authUrl
=
twitterProvider
.
getAuthorizationUrl
(
new
HttpUserSession
(
request
));
final
String
authUrl
=
twitterProvider
.
getAuthorizationUrl
(
new
HttpUserSession
(
request
));
result
=
new
RedirectView
(
authUrl
);
result
=
new
RedirectView
(
authUrl
);
}
else
if
(
"facebook"
.
equals
(
type
))
{
}
else
if
(
facebookEnabled
&&
"facebook"
.
equals
(
type
))
{
facebookProvider
.
setFields
(
"id,link"
);
facebookProvider
.
setFields
(
"id,link"
);
facebookProvider
.
setScope
(
""
);
facebookProvider
.
setScope
(
""
);
final
String
authUrl
=
facebookProvider
.
getAuthorizationUrl
(
new
HttpUserSession
(
request
));
final
String
authUrl
=
facebookProvider
.
getAuthorizationUrl
(
new
HttpUserSession
(
request
));
result
=
new
RedirectView
(
authUrl
);
result
=
new
RedirectView
(
authUrl
);
}
else
if
(
"google"
.
equals
(
type
))
{
}
else
if
(
googleEnabled
&&
"google"
.
equals
(
type
))
{
final
String
authUrl
=
googleProvider
.
getAuthorizationUrl
(
new
HttpUserSession
(
request
));
final
String
authUrl
=
googleProvider
.
getAuthorizationUrl
(
new
HttpUserSession
(
request
));
result
=
new
RedirectView
(
authUrl
);
result
=
new
RedirectView
(
authUrl
);
}
else
{
response
.
setStatus
(
HttpStatus
.
BAD_REQUEST
.
value
());
}
}
return
result
;
return
result
;
...
...
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