Merge branch 'release/0.10.0'

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

View File

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

View File

@ -292,7 +292,9 @@ public class QJavalinImplementation
get("/count", QJavalinImplementation::dataCount); get("/count", QJavalinImplementation::dataCount);
post("/count", QJavalinImplementation::dataCount); post("/count", QJavalinImplementation::dataCount);
get("/export", QJavalinImplementation::dataExportWithoutFilename); get("/export", QJavalinImplementation::dataExportWithoutFilename);
post("/export", QJavalinImplementation::dataExportWithoutFilename);
get("/export/{filename}", QJavalinImplementation::dataExportWithFilename); get("/export/{filename}", QJavalinImplementation::dataExportWithFilename);
post("/export/{filename}", QJavalinImplementation::dataExportWithFilename);
get("/possibleValues/{fieldName}", QJavalinImplementation::possibleValues); 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. // todo - add put and/or patch at this level (without a primaryKey) to do a bulk update based on primaryKeys in the records.
@ -357,26 +359,19 @@ public class QJavalinImplementation
// either with a "Basic " prefix (for a username:password pair) // // 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) // // or with a "Bearer " prefix (for a token that can be handled the same as a sessionId cookie) //
///////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////
String basicPrefix = "Basic "; processAuthorizationValue(authenticationContext, authorizationHeaderValue);
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 header value did not have Basic or Bearer prefix. [" + authorizationHeaderValue + "]");
}
} }
else else
{ {
LOG.debug("Neither [" + SESSION_ID_COOKIE_NAME + "] cookie nor [Authorization] header was present in request."); 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); QSession session = authenticationModule.createSession(qInstance, authenticationContext);
@ -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 + "]");
}
}
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/