Skip to content

RBAC checking via custom authHandler function + SAF query interpretation#281

Open
DivergentEuropeans wants to merge 82 commits intov1.x/stagingfrom
RBAC-support
Open

RBAC checking via custom authHandler function + SAF query interpretation#281
DivergentEuropeans wants to merge 82 commits intov1.x/stagingfrom
RBAC-support

Conversation

@DivergentEuropeans
Copy link
Copy Markdown
Member

@DivergentEuropeans DivergentEuropeans commented Apr 13, 2021

Similar to what zlux-server-framework\plugins\sso-auth\lib\safprofile.js does

Turns a SAF URL into a SAF query i.e. /plugins GET undefined
->
ZLUX.0.COR.GET.PLUGINS

ZSS now uses RBAC for Http services

List of exclusions:
'/login', '/logout', '/password', '/unixfile', '/datasetContents', '/VSAMdatasetContents', '/datasetMetadata', '/omvs', '/security-mgmt'

PR (1 of 2)
PR 2: zowe/zowe-common-c#218

Signed-off-by: Leanid Astrakou lastrakou@rocketsoftware.com

Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Copy link
Copy Markdown
Contributor

@timgerstel timgerstel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems okay to me

Comment thread c/authService.c Outdated
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Comment thread c/authService.c Outdated
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Copy link
Copy Markdown
Contributor

@ifakhrutdinov ifakhrutdinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DivergentEuropeans, please see my comments.

In addition to the comments:

Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
Comment thread c/authService.c Outdated
@DivergentEuropeans

This comment has been minimized.

Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
@DivergentEuropeans DivergentEuropeans changed the title Initial commit for SAF query interpretation methods (WIP) Initial commit for SAF query interpretation + RBAC checking May 24, 2021
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Comment thread h/authService.h Outdated
Leonty Chudinov and others added 6 commits July 7, 2021 11:14
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
…into RBAC-support

Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
@DivergentEuropeans
Copy link
Copy Markdown
Member Author

TODO: When we login, the App server interprets the GET plugins query as

ZLUX.0.COR.GET.PLUGINS

yet ZSS interprets it as

ZLUX.0.COR.GET.SAF-AUTH.ZLUX.0.COR.GET.PLUGINS.READ

for some reason. Need to investigate if this is intended behaviour...

DivergentEuropeans and others added 20 commits August 26, 2021 10:39
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
…tion-for-saf-auth-service

Disable RBAC authorization for saf-auth service
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Signed-off-by: Leanid Astrakou <lastrakou@rocketsoftware.com>
Comment thread c/authService.c
const char *class = SAF_CLASS;

int rc = zisCheckEntity(privilegedServerName, userName, class, entity, access, &reqStatus);
zowelog(NULL, LOG_COMP_ID_SECURITY, ZOWE_LOG_DEBUG2,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add zowedump for reqStatus so you can debug what's happening.

Comment thread c/authService.c Outdated
while (pathSegment != NULL) {
snprintf(urlSegment, sizeof(urlSegment), "%s", pathSegment->string);
strupcase(urlSegment);
if (rootServiceName == NULL)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can never be NULL. And if it was, you wouldn't want to call snprintf with rootServiceName as the destination.

Comment thread c/authService.c
Comment on lines +268 to +280
case 0:
snprintf(productCode, sizeof(productCode), urlSegment);
break;
case 1:
break;
case 2:
snprintf(pluginID, sizeof(pluginID), urlSegment);
break;
case 3:
break;
case 4:
snprintf(serviceName, sizeof(serviceName), urlSegment);
break;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these cases are never entered, these buffers will stay uninitialized, this will cause issues in setProfileNameAttribs and makeProfileName.

Comment thread c/authService.c
setProfileNameAttribs(pluginID, serviceName, type, scope, subUrl);
int pluginIDLen = strlen(pluginID);
for (int index = 0; index < pluginIDLen; index++) {
if (pluginID[index] == '.') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pluginID may be uninitialized.

Comment thread c/authService.c
productCode,
instanceID,
pluginID,
rootServiceName,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rootServiceName may be uninitialized.

Comment thread c/datasetService.c

HttpService *httpService = makeGeneratedService("datasetContents", "/datasetContents/**");
httpService->authType = SERVICE_AUTH_NATIVE_WITH_SESSION_TOKEN;
httpService->authorizationType = SERVICE_AUTHORIZATION_TYPE_NONE;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do 3rd party plugins have to do this as well and then rebuild the binaries, or will everything work without recompilation?

Comment thread c/zss.c Outdated
RbacAuthorizationData *rbacData = userData;

char method[16];
snprintf(method, sizeof(method), "%s", request->method);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate the method length and not proceed if it's too long?

Comment thread c/zss.c Outdated
return rbacParm;
}

static int getZoweInstanceId() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare functions that take no parameters using a void argument, for example:

int foo(void);

Otherwise it's considered "unspecified number of parameters" by the standard.

Comment thread c/zss.c Outdated
return;
}
RbacAuthorizationData *rbacData = (RbacAuthorizationData*) safeMalloc(sizeof(*rbacData), "Rbac Authorization Data");
if (rbacData) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we report an error and maybe terminate if this is NULL? If we silently do nothing here, ZSS is less protected and that's not going to be discovered.

Comment thread h/authService.h Outdated
#include "httpserver.h"
#include "dataservice.h"

#define SAF_CLASS "ZOWE"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you be more specific? ZOWE_SAF_CLASS would be clearer.

Leonty Chudinov added 2 commits November 29, 2021 10:27
Signed-off-by: Leonty Chudinov <lchudinov@rocketsoftware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

4 participants