Skip to content

Commit c95efe3

Browse files
Support Authorize: Bearer <KEY> as equivalent to apikey: <KEY>
1 parent 9d910c7 commit c95efe3

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

api/src/org/labkey/api/security/SecurityManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.commons.collections4.MultiValuedMap;
2929
import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
3030
import org.apache.commons.lang3.StringUtils;
31+
import org.apache.commons.lang3.Strings;
3132
import org.apache.logging.log4j.Level;
3233
import org.apache.logging.log4j.Logger;
3334
import org.jetbrains.annotations.NotNull;
@@ -662,6 +663,13 @@ public static Pair<User, HttpServletRequest> attemptAuthentication(HttpServletRe
662663
// Passing via the "apikey" HTTP header is our preferred approach and used by most
663664
// LabKey client API implementations
664665
String apiKey = request.getHeader(API_KEY);
666+
667+
if (null == apiKey)
668+
{
669+
String authorization = request.getHeader("Authorization");
670+
if (Strings.CS.startsWith(authorization, "Bearer "))
671+
apiKey = StringUtils.trimToNull(authorization.substring("Bearer ".length()));
672+
}
665673

666674
if (null == apiKey)
667675
{

0 commit comments

Comments
 (0)