Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

Commit

Permalink
fix: basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
joscha committed Sep 24, 2018
1 parent 3f70e03 commit 02138d9
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> 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);
Expand Down

0 comments on commit 02138d9

Please sign in to comment.