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
45b5c4db
Commit
45b5c4db
authored
5 years ago
by
Tom Käsler
Browse files
Options
Downloads
Patches
Plain Diff
Add tracing messages to ws auth handling for better debugging
parent
884f6446
Branches
Branches containing commit
1 merge request
!139
Add tracing on incoming messages
Pipeline
#29387
passed with warnings with stages
in 1 minute and 26 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/thm/arsnova/websocket/handler/AuthChannelInterceptorAdapter.java
+5
-0
5 additions, 0 deletions
...nova/websocket/handler/AuthChannelInterceptorAdapter.java
with
5 additions
and
0 deletions
src/main/java/de/thm/arsnova/websocket/handler/AuthChannelInterceptorAdapter.java
+
5
−
0
View file @
45b5c4db
...
@@ -31,13 +31,16 @@ public class AuthChannelInterceptorAdapter implements ChannelInterceptor {
...
@@ -31,13 +31,16 @@ public class AuthChannelInterceptorAdapter implements ChannelInterceptor {
@Nullable
@Nullable
@Override
@Override
public
Message
<?>
preSend
(
final
Message
<?>
message
,
final
MessageChannel
channel
)
{
public
Message
<?>
preSend
(
final
Message
<?>
message
,
final
MessageChannel
channel
)
{
logger
.
trace
(
"Inspecting incoming message: {}"
,
message
);
final
StompHeaderAccessor
accessor
=
StompHeaderAccessor
.
wrap
(
message
);
final
StompHeaderAccessor
accessor
=
StompHeaderAccessor
.
wrap
(
message
);
final
String
sessionId
=
accessor
.
getSessionId
();
final
String
sessionId
=
accessor
.
getSessionId
();
if
(
accessor
.
getCommand
()
!=
null
&&
accessor
.
getCommand
().
equals
(
StompCommand
.
CONNECT
))
{
if
(
accessor
.
getCommand
()
!=
null
&&
accessor
.
getCommand
().
equals
(
StompCommand
.
CONNECT
))
{
// user needs to authorize
// user needs to authorize
logger
.
trace
(
"Incoming message is a connect command"
);
final
List
<
String
>
tokenList
=
accessor
.
getNativeHeader
(
"token"
);
final
List
<
String
>
tokenList
=
accessor
.
getNativeHeader
(
"token"
);
if
(
tokenList
!=
null
&&
tokenList
.
size
()
>
0
)
{
if
(
tokenList
!=
null
&&
tokenList
.
size
()
>
0
)
{
logger
.
trace
(
"Adding token {} to the ws session mapping"
,
tokenList
.
get
(
0
));
final
String
token
=
tokenList
.
get
(
0
);
final
String
token
=
tokenList
.
get
(
0
);
service
.
addWsSessionToJwtMapping
(
sessionId
,
token
);
service
.
addWsSessionToJwtMapping
(
sessionId
,
token
);
}
else
{
}
else
{
...
@@ -46,9 +49,11 @@ public class AuthChannelInterceptorAdapter implements ChannelInterceptor {
...
@@ -46,9 +49,11 @@ public class AuthChannelInterceptorAdapter implements ChannelInterceptor {
return
null
;
return
null
;
}
}
}
else
{
}
else
{
logger
.
trace
(
"Incoming message is anything but a connect command"
);
final
List
<
String
>
userIdList
=
accessor
.
getNativeHeader
(
"ars-user-id"
);
final
List
<
String
>
userIdList
=
accessor
.
getNativeHeader
(
"ars-user-id"
);
if
(
userIdList
!=
null
&&
userIdList
.
size
()
>
0
)
{
if
(
userIdList
!=
null
&&
userIdList
.
size
()
>
0
)
{
// user-id is given, check for auth
// user-id is given, check for auth
logger
.
trace
(
"Checking user id with ws session mapping"
);
final
String
userId
=
userIdList
.
get
(
0
);
final
String
userId
=
userIdList
.
get
(
0
);
final
User
u
=
service
.
getAuthenticatedUserByWsSession
(
sessionId
);
final
User
u
=
service
.
getAuthenticatedUserByWsSession
(
sessionId
);
if
(
u
==
null
||
!
userId
.
equals
(
u
.
getId
()))
{
if
(
u
==
null
||
!
userId
.
equals
(
u
.
getId
()))
{
...
...
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