Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 91223aea
authored
Jan 09, 2018
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some checks to stuff broken by domain migration from thread-store to username
1 parent
1acfee20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
6 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/CardTemplateBean.java
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/UserLoginUtils.java
code/moya-web/src/main/java/fi/codecrew/moya/HostnameFilter.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/UserRestView.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/CardTemplateBean.java
View file @
91223ae
...
...
@@ -168,7 +168,7 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
public
PrintedCard
checkPrintedCard
(
EventUser
user
)
{
logger
.
info
(
"Checking printed card"
);
user
=
eventUserFacade
.
find
(
user
.
getId
()
);
user
=
eventUserFacade
.
reload
(
user
);
LanEvent
currEvent
=
eventBean
.
getCurrentEvent
();
List
<
PrintedCard
>
myCards
=
printedcardfacade
.
getCards
(
user
);
...
...
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/UserLoginUtils.java
View file @
91223ae
...
...
@@ -32,6 +32,12 @@ public class UserLoginUtils {
}
public
static
String
getUsernameFromJaasString
(
String
username
)
{
return
username
.
split
(
"@[^@]+$"
)[
0
];
String
[]
splitted
=
username
.
split
(
"@[^@]+$"
);
String
ret
=
null
;
if
(
splitted
.
length
>
0
)
{
ret
=
splitted
[
0
];
}
return
ret
;
}
}
code/moya-web/src/main/java/fi/codecrew/moya/HostnameFilter.java
View file @
91223ae
...
...
@@ -246,7 +246,7 @@ public class HostnameFilter implements Filter {
restAuthStr
=
httpRequest
.
getHeader
(
"Authorization"
);
// }
if
(
restAuthStr
==
null
)
{
if
(
restAuthStr
==
null
&&
httpRequest
.
getParameter
(
"appkey"
)
!=
null
)
{
StringBuilder
hashBuilder
=
new
StringBuilder
();
hashBuilder
.
append
(
JaasBeanLocal
.
REST_PREFIX
);
...
...
@@ -257,9 +257,15 @@ public class HostnameFilter implements Filter {
hashBuilder
.
append
(
httpRequest
.
getPathInfo
());
restAuthStr
=
hashBuilder
.
toString
();
}
boolean
ret
=
true
;
try
{
httpRequest
.
login
(
'@'
+
parseHostname
(
httpRequest
),
restAuthStr
);
if
(
restAuthStr
==
null
)
{
throw
new
ServletException
(
"No auth data"
);
}
final
String
username
=
"@"
+
parseHostname
(
httpRequest
);
logger
.
info
(
"Logging in with username {} and password {}"
,
username
,
restAuthStr
);
httpRequest
.
login
(
username
,
restAuthStr
);
}
catch
(
ServletException
loginEx
)
{
ret
=
false
;
logger
.
info
(
"Rest api authentication failed for path "
+
httpRequest
.
getPathInfo
()
+
" "
...
...
@@ -296,10 +302,11 @@ public class HostnameFilter implements Filter {
logbean
.
sendMessage
(
MoyaEventType
.
USER_PERMISSION_VIOLATION
,
"Hostname mismatch privilege escalation! User '"
,
httpRequest
.
getUserPrincipal
(),
"' tried to change hostname from '"
,
userDomain
,
"' to '"
,
hostname
,
","
);
throw
new
RuntimeException
(
"Hostname mismatch!"
);
throw
new
RuntimeException
(
"Hostname mismatch! Expected: "
+
hostname
+
" but logged in as "
+
userDomain
);
}
}
BortalLocalContextHolder
.
setInDevelopmentMode
(
developmentMode
);
return
hostname
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/UserRestView.java
View file @
91223ae
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
Attach a file
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 post a comment