Skip to content

Commit

Permalink
HPCC-30111 Look up internal file scope name
Browse files Browse the repository at this point in the history
Previously, "hpccinternal::" was hardcoded.

Signed-off-by: Dan S. Camper <[email protected]>
  • Loading branch information
dcamper committed Aug 17, 2023
1 parent 9e51f66 commit e9d94de
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions system/security/plugins/jwtSecurity/jwtSecurity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ class CJwtSecurityManager : implements IDaliLdapConnection, public CBaseSecurity

if (secretsName.empty())
throw makeStringException(-1, "CJwtSecurityManager: secretsName not found in configuration");

// Grab a copy of the name of the internal file scope
hpccInternalScope = queryDfsXmlBranchName(DXB_Internal);
hpccInternalScope += "::";
}

virtual ~CJwtSecurityManager()
Expand Down Expand Up @@ -794,10 +798,16 @@ class CJwtSecurityManager : implements IDaliLdapConnection, public CBaseSecurity
{
// Scope hpccinternal::<username> always has full access for their own scope, but
// explicitly denied when attempting to access someone else's
// hpccinternal::<username> scope
if (resourceName && strncmp(resourceName, "hpccinternal::", 14) == 0)
// hpccinternal::<username> scope; note that resourceName may contain more
// scope levels
if (startsWithIgnoreCase(resourceName, hpccInternalScope.c_str()))
{
if (strisame(&resourceName[14], user.getName()))
// Extract the username provided in the resourceName
StringBuffer rezUserName;
for (const char * p = &resourceName[hpccInternalScope.length()]; *p && *p != ':'; p++)
rezUserName.append(*p);

if (strisame(rezUserName.str(), user.getName()))
accessFlag = SecAccess_Full;
else
accessFlag = SecAccess_None;
Expand Down Expand Up @@ -1059,6 +1069,7 @@ class CJwtSecurityManager : implements IDaliLdapConnection, public CBaseSecurity
std::string keyContents; //!< Contents of secret key; @see ensureKeyLoaded()
bool keyIsPublicKey; //!< True if keyContents contains a public key, false otherwise
CDALIKVStore daliStore; //!< Handle to Dali's key/value store (external token cache)
std::string hpccInternalScope; //!< File scope used by the cluster for interim results
static const SecFeatureSet implementedFeaturesMask = SMF_Authorize
| SMF_AuthorizeEx_Named
| SMF_AuthorizeFileScope_List
Expand Down

0 comments on commit e9d94de

Please sign in to comment.