From 02138d9b25a3d9ec6f0d04d2de97b4fb243801dc Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Tue, 25 Sep 2018 00:41:46 +1000 Subject: [PATCH] fix: basic auth --- .../pa/providers/wwwauth/WWWAuthenticateProvider.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/app/com/feth/play/module/pa/providers/wwwauth/WWWAuthenticateProvider.java b/code/app/com/feth/play/module/pa/providers/wwwauth/WWWAuthenticateProvider.java index 49cbc38b..dee68fd5 100644 --- a/code/app/com/feth/play/module/pa/providers/wwwauth/WWWAuthenticateProvider.java +++ b/code/app/com/feth/play/module/pa/providers/wwwauth/WWWAuthenticateProvider.java @@ -15,6 +15,8 @@ */ package com.feth.play.module.pa.providers.wwwauth; +import java.util.Optional; + import com.feth.play.module.pa.PlayAuthenticate; import com.feth.play.module.pa.exceptions.AuthException; import com.feth.play.module.pa.providers.AuthProvider; @@ -99,11 +101,12 @@ private Result deny(Context context) { @Override public Object authenticate(Context context, Object payload) throws AuthException { - String auth = context.request().header("Authorization").get(); + Optional authHeader = context.request().header("Authorization"); - if (auth == null) { + if (!authHeader.isPresent()) { return deny(context); } + String auth = authHeader.get(); int ix = auth.indexOf(32); if (ix == -1 || !authScheme().equalsIgnoreCase(auth.substring(0,ix))) { return deny(context);