Merge branch 'dev' of github.com:Kingsrook/qqq into dev

This commit is contained in:
Tim Chamberlain
2023-01-13 15:56:56 -06:00
2 changed files with 38 additions and 18 deletions

View File

@ -43,7 +43,7 @@
</modules>
<properties>
<revision>0.10.0-SNAPSHOT</revision>
<revision>0.11.0-SNAPSHOT</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

View File

@ -292,7 +292,9 @@ public class QJavalinImplementation
get("/count", QJavalinImplementation::dataCount);
post("/count", QJavalinImplementation::dataCount);
get("/export", QJavalinImplementation::dataExportWithoutFilename);
post("/export", QJavalinImplementation::dataExportWithoutFilename);
get("/export/{filename}", QJavalinImplementation::dataExportWithFilename);
post("/export/{filename}", QJavalinImplementation::dataExportWithFilename);
get("/possibleValues/{fieldName}", QJavalinImplementation::possibleValues);
// todo - add put and/or patch at this level (without a primaryKey) to do a bulk update based on primaryKeys in the records.
@ -357,27 +359,20 @@ public class QJavalinImplementation
// either with a "Basic " prefix (for a username:password pair) //
// or with a "Bearer " prefix (for a token that can be handled the same as a sessionId cookie) //
/////////////////////////////////////////////////////////////////////////////////////////////////
String basicPrefix = "Basic ";
String bearerPrefix = "Bearer ";
if(authorizationHeaderValue.startsWith(basicPrefix))
{
authorizationHeaderValue = authorizationHeaderValue.replaceFirst(basicPrefix, "");
authenticationContext.put(BASIC_AUTH_NAME, authorizationHeaderValue);
}
else if(authorizationHeaderValue.startsWith(bearerPrefix))
{
authorizationHeaderValue = authorizationHeaderValue.replaceFirst(bearerPrefix, "");
authenticationContext.put(SESSION_ID_COOKIE_NAME, authorizationHeaderValue);
processAuthorizationValue(authenticationContext, authorizationHeaderValue);
}
else
{
LOG.debug("Authorization header value did not have Basic or Bearer prefix. [" + authorizationHeaderValue + "]");
}
String authorizationFormValue = context.formParam("Authorization");
if(StringUtils.hasContent(authorizationFormValue))
{
processAuthorizationValue(authenticationContext, authorizationFormValue);
}
else
{
LOG.debug("Neither [" + SESSION_ID_COOKIE_NAME + "] cookie nor [Authorization] header was present in request.");
}
}
QSession session = authenticationModule.createSession(qInstance, authenticationContext);
input.setSession(session);
@ -408,6 +403,31 @@ public class QJavalinImplementation
/*******************************************************************************
**
*******************************************************************************/
private static void processAuthorizationValue(Map<String, String> authenticationContext, String authorizationHeaderValue)
{
String basicPrefix = "Basic ";
String bearerPrefix = "Bearer ";
if(authorizationHeaderValue.startsWith(basicPrefix))
{
authorizationHeaderValue = authorizationHeaderValue.replaceFirst(basicPrefix, "");
authenticationContext.put(BASIC_AUTH_NAME, authorizationHeaderValue);
}
else if(authorizationHeaderValue.startsWith(bearerPrefix))
{
authorizationHeaderValue = authorizationHeaderValue.replaceFirst(bearerPrefix, "");
authenticationContext.put(SESSION_ID_COOKIE_NAME, authorizationHeaderValue);
}
else
{
LOG.debug("Authorization value did not have Basic or Bearer prefix. [" + authorizationHeaderValue + "]");
}
}
/*******************************************************************************
**
*******************************************************************************/