Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-server
Commits
36cfdfc3
Verified
Commit
36cfdfc3
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
Handle logout
parent
d4cdc595
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!58
REL: prepare release 0.7.2
,
!45
F grpc f acm
Pipeline
#16253
passed
3 years ago
Stage: info
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/caosdb/server/grpc/AuthInterceptor.java
+15
-4
15 additions, 4 deletions
src/main/java/org/caosdb/server/grpc/AuthInterceptor.java
with
15 additions
and
4 deletions
src/main/java/org/caosdb/server/grpc/AuthInterceptor.java
+
15
−
4
View file @
36cfdfc3
...
@@ -50,6 +50,12 @@ public class AuthInterceptor implements ServerInterceptor {
...
@@ -50,6 +50,12 @@ public class AuthInterceptor implements ServerInterceptor {
Pattern
.
compile
(
"^\\s*"
+
AuthenticationUtils
.
SESSION_TOKEN_COOKIE
+
"\\s*=\\s*"
);
Pattern
.
compile
(
"^\\s*"
+
AuthenticationUtils
.
SESSION_TOKEN_COOKIE
+
"\\s*=\\s*"
);
public
static
final
Predicate
<
String
>
SESSION_TOKEN_COOKIE_PREFIX_PREDICATE
=
public
static
final
Predicate
<
String
>
SESSION_TOKEN_COOKIE_PREFIX_PREDICATE
=
SESSION_TOKEN_COOKIE_PREFIX_PATTERN
.
asPredicate
();
SESSION_TOKEN_COOKIE_PREFIX_PATTERN
.
asPredicate
();
public
final
Metadata
expiredSessionMetadata
()
{
Metadata
metadata
=
new
Metadata
();
metadata
.
put
(
CookieSetter
.
SET_COOKIE
,
CookieSetter
.
EXPIRED_SESSION_COOKIE
);
return
metadata
;
}
/**
/**
* A no-op listener. This class is used for failed authentications. We couldn't return a null
* A no-op listener. This class is used for failed authentications. We couldn't return a null
* instead because the documentation of the {@link ServerInterceptor} explicitely forbids it.
* instead because the documentation of the {@link ServerInterceptor} explicitely forbids it.
...
@@ -107,7 +113,7 @@ public class AuthInterceptor implements ServerInterceptor {
...
@@ -107,7 +113,7 @@ public class AuthInterceptor implements ServerInterceptor {
}
else
{
}
else
{
status
=
Status
.
UNAUTHENTICATED
.
withDescription
(
"Unsupported authentication scheme."
);
status
=
Status
.
UNAUTHENTICATED
.
withDescription
(
"Unsupported authentication scheme."
);
}
}
call
.
close
(
status
,
new
Metadata
());
call
.
close
(
status
,
expiredSession
Metadata
());
return
new
NoOpListener
<
ReqT
>();
return
new
NoOpListener
<
ReqT
>();
}
}
...
@@ -130,7 +136,7 @@ public class AuthInterceptor implements ServerInterceptor {
...
@@ -130,7 +136,7 @@ public class AuthInterceptor implements ServerInterceptor {
final
Status
status
=
final
Status
status
=
Status
.
UNAUTHENTICATED
.
withDescription
(
Status
.
UNAUTHENTICATED
.
withDescription
(
"Authentication failed. SessionToken was invalid."
);
"Authentication failed. SessionToken was invalid."
);
call
.
close
(
status
,
new
Metadata
());
call
.
close
(
status
,
expiredSession
Metadata
());
return
new
NoOpListener
<
ReqT
>();
return
new
NoOpListener
<
ReqT
>();
}
}
}
}
...
@@ -160,7 +166,7 @@ public class AuthInterceptor implements ServerInterceptor {
...
@@ -160,7 +166,7 @@ public class AuthInterceptor implements ServerInterceptor {
final
Status
status
=
final
Status
status
=
Status
.
UNAUTHENTICATED
.
withDescription
(
Status
.
UNAUTHENTICATED
.
withDescription
(
"Authentication failed. Username or password wrong."
);
"Authentication failed. Username or password wrong."
);
call
.
close
(
status
,
new
Metadata
());
call
.
close
(
status
,
expiredSession
Metadata
());
return
new
NoOpListener
<
ReqT
>();
return
new
NoOpListener
<
ReqT
>();
}
}
}
}
...
@@ -203,7 +209,10 @@ public class AuthInterceptor implements ServerInterceptor {
...
@@ -203,7 +209,10 @@ public class AuthInterceptor implements ServerInterceptor {
final
class
CookieSetter
<
ReqT
,
RespT
>
final
class
CookieSetter
<
ReqT
,
RespT
>
extends
ForwardingServerCall
.
SimpleForwardingServerCall
<
ReqT
,
RespT
>
{
extends
ForwardingServerCall
.
SimpleForwardingServerCall
<
ReqT
,
RespT
>
{
private
static
final
Key
<
String
>
SET_COOKIE
=
public
static
final
String
EXPIRED_SESSION_COOKIE
=
AuthenticationUtils
.
SESSION_TOKEN_COOKIE
+
"=expired; Path=/; HttpOnly; SameSite=Strict; Max-Age=0"
;
public
static
final
Key
<
String
>
SET_COOKIE
=
Key
.
of
(
"Set-Cookie"
,
Metadata
.
ASCII_STRING_MARSHALLER
);
Key
.
of
(
"Set-Cookie"
,
Metadata
.
ASCII_STRING_MARSHALLER
);
protected
CookieSetter
(
ServerCall
<
ReqT
,
RespT
>
delegate
)
{
protected
CookieSetter
(
ServerCall
<
ReqT
,
RespT
>
delegate
)
{
...
@@ -244,6 +253,8 @@ final class CookieSetter<ReqT, RespT>
...
@@ -244,6 +253,8 @@ final class CookieSetter<ReqT, RespT>
+
getSessionTimeoutSeconds
());
+
getSessionTimeoutSeconds
());
}
}
}
}
}
else
{
headers
.
put
(
SET_COOKIE
,
EXPIRED_SESSION_COOKIE
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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