Skip to content

Commit

Permalink
Merge pull request #6 from RADAR-base/fix-cookie-support-for-token
Browse files Browse the repository at this point in the history
hotfix: add support to token from cookies
  • Loading branch information
nivemaham authored Oct 24, 2019
2 parents 64434f4 + 5cf188f commit 202346c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}
dependencies {
api("org.radarbase:radar-jersey:0.2.2.1")
api("org.radarbase:radar-jersey:0.2.2.2")
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

description = 'Library for Jersey authorization, exception handling and configuration with the RADAR platform'
group = 'org.radarbase'
version = '0.2.2.1'
version = '0.2.2.2'

ext {
githubRepoName = 'RADAR-base/radar-jersey'
Expand Down
16 changes: 11 additions & 5 deletions src/main/kotlin/org/radarbase/jersey/auth/AuthValidator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ interface AuthValidator {
val authorizationHeader = request.getHeaderString("Authorization")

// Check if the HTTP Authorization header is present and formatted correctly
if (authorizationHeader == null
|| !authorizationHeader.startsWith(AuthenticationFilter.BEARER, ignoreCase = true)) {
return null
if (authorizationHeader != null
&& authorizationHeader.startsWith(AuthenticationFilter.BEARER, ignoreCase = true)) {
// Extract the token from the HTTP Authorization header
return authorizationHeader.substring(AuthenticationFilter.BEARER.length).trim { it <= ' ' }
}

// Extract the token from the HTTP Authorization header
return authorizationHeader.substring(AuthenticationFilter.BEARER.length).trim { it <= ' ' }
// Extract the token from the Authorization cookie
val authorizationCookie = request.cookies["authorizationBearer"]
if (authorizationCookie != null) {
return authorizationCookie.value
}

return null
}
}

0 comments on commit 202346c

Please sign in to comment.