From b9d3a1ab5d34949386c89e6d04ebde33dec63787 Mon Sep 17 00:00:00 2001 From: ulrich Date: Tue, 15 Jun 2021 14:59:14 +0000 Subject: [PATCH] getRealm --- src/de/uhilger/httpserver/oauth/BearerAuthenticator.java | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) diff --git a/src/de/uhilger/httpserver/oauth/BearerAuthenticator.java b/src/de/uhilger/httpserver/oauth/BearerAuthenticator.java index 8c3805f..5ec83be 100644 --- a/src/de/uhilger/httpserver/oauth/BearerAuthenticator.java +++ b/src/de/uhilger/httpserver/oauth/BearerAuthenticator.java @@ -22,7 +22,7 @@ import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpPrincipal; import de.uhilger.httpserver.auth.realm.Realm; -import de.uhilger.httpserver.base.handler.HttpResponder; +import de.uhilger.httpserver.base.HttpResponder; import io.jsonwebtoken.Claims; import io.jsonwebtoken.JwtException; import io.jsonwebtoken.Jwts; @@ -228,6 +228,22 @@ if(parts != null && parts.length > 1) { token = parts[1].trim(); } + } else { + // unschoen, aber fuer Image-Links in HTML-Inhalten + // mit Query versuchen + // z.B. + // GET /resource?access_token=mF_9.B5f-4.1JqM HTTP/1.1 + // Host: server.example.com + String query = exchange.getRequestURI().getQuery(); + if(query != null && query.toLowerCase().contains("access_token")) { + String[] parts = query.split("&"); + for(String part : parts) { + String[] keyVal = part.split("="); + if(keyVal[0].equalsIgnoreCase("access_token")) { + token = keyVal[1].trim(); + } + } + } } return token; } @@ -333,6 +349,10 @@ this.realm = realm; } + public Realm getRealm() { + return realm; + } + public void setWWWAuthRealm(String wwwAuthRealm) { this.wwwAuthRealm = wwwAuthRealm; } -- Gitblit v1.9.3