Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Certificate Authentication with R_usermap #584

Merged
merged 7 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions c/zis/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,22 @@ int zisCheckUsernameAndPassword(const CrossMemoryServerName *serverName,
return authRequest(serverName, &parmList, status);
}

int zisCheckUsername(const CrossMemoryServerName *serverName,
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this new xmem service do?

const char *userName,
ZISAuthServiceStatus *status) {
AuthServiceParmList parmList = {0};

memcpy(&parmList.eyecatcher[0], ZIS_AUTH_SERVICE_PARMLIST_EYECATCHER,
sizeof(parmList.eyecatcher));
parmList.fc = ZIS_AUTH_SERVICE_PARMLIST_FC_VERIFY_USER;
if (strlen(userName) >= sizeof (parmList.userIDNullTerm)) {
status->baseStatus.serviceRC = RC_ZIS_AUTHSRV_INPUT_STRING_TOO_LONG;
return RC_ZIS_SRVC_SERVICE_FAILED;
}
strncpy(parmList.userIDNullTerm, userName, sizeof(parmList.userIDNullTerm));
return authRequest(serverName, &parmList, status);
}

int zisCheckEntity(const CrossMemoryServerName *serverName,
const char *userName, const char *class, const char *entity,
int access, ZISAuthServiceStatus *status) {
Expand Down
50 changes: 50 additions & 0 deletions c/zis/services/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,53 @@

#define ZIS_PARMLIB_PARM_AUTH_USER_CLASS CMS_PROD_ID".AUTH.CLASS"

static int handleVerifyUser(AuthServiceParmList *parmList,
const CrossMemoryServerGlobalArea *globalArea) {
ACEE *acee = NULL;
int safRC = 0, racfRC = 0, racfRsn = 0;
int deleteSAFRC = 0, deleteRACFRC = 0, deleteRACFRsn = 0;
int rc = RC_ZIS_AUTHSRV_OK;

CMS_DEBUG(globalArea, "handleVerifyUser(): username = %s\n",
parmList->userIDNullTerm);

if (parmList->_padding0[0] & ZIS_AUTH_SERVICE_SAFIDT_OPTION_RESERVED) {
return RC_ZIS_AUTHSRV_BAD_SAF_SERVICE_VERSION;
}

int options = VERIFY_CREATE | VERIFY_WITHOUT_PASSWORD;

safRC = safVerify(options,
parmList->userIDNullTerm,
NULL,
&acee,
&racfRC,
&racfRsn);

CMS_DEBUG(globalArea, "safVerify(VERIFY_CREATE) safStatus = %d, RACF RC = %d, "
"RSN = %d, ACEE=0x%p\n", safRC, racfRC, racfRsn, acee);

if (safRC != 0) {
rc = RC_ZIS_AUTHSRV_SAF_ERROR;
goto acee_deleted;
}
deleteSAFRC = safVerify(VERIFY_DELETE, NULL, NULL, &acee, &deleteRACFRC,
&deleteRACFRsn);
CMS_DEBUG(globalArea, "safVerify(VERIFY_DELETE) safStatus = %d, RACF RC = %d, "
"RSN = %d, ACEE=0x%p\n", deleteSAFRC, deleteRACFRC, deleteRACFRsn,
acee);
if (deleteSAFRC != 0) {
rc = RC_ZIS_AUTHSRV_DELETE_FAILED;
}
acee_deleted:

FILL_SAF_STATUS(&parmList->safStatus, safRC, racfRC, racfRsn);
CMS_DEBUG(globalArea, "handleVerifyPassword() done\n");
return rc;


}

static int handleVerifyPassword(AuthServiceParmList *parmList,
const CrossMemoryServerGlobalArea *globalArea) {
ACEE *acee = NULL;
Expand Down Expand Up @@ -393,6 +440,9 @@ int zisAuthServiceFunction(CrossMemoryServerGlobalArea *globalArea,
case ZIS_AUTH_SERVICE_PARMLIST_FC_GENERATE_TOKEN:
handlerRC = handleGenerateToken(&localParmList, globalArea);
break;
case ZIS_AUTH_SERVICE_PARMLIST_FC_VERIFY_USER:
handlerRC = handleVerifyUser(&localParmList, globalArea);
break;
default:
handlerRC = RC_ZIS_AUTHSRV_UNKNOWN_FUNCTION_CODE;
}
Expand Down
4 changes: 2 additions & 2 deletions c/zss.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,16 @@ static int extractAuthorizationFromJson(HttpService *service, HttpRequest *reque
} else {
request->username = jsonAsString(username);
}

if (password == NULL){
return -1;
} else if (!jsonIsString(password)){
return -1;
} else {
request->password = jsonAsString(password);
}
return 0;
}
return 0;
return -1;
}

static
Expand Down
5 changes: 5 additions & 0 deletions h/zis/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ typedef struct ZISAuthServiceStatus_tag {
_ZIS_FORMAT_CALL_STATUS_TMPL($rc, $status, $printf, \
_ZIS_AUTH_SERVICE_ERROR_CASES, ZIS_AUTH_RC_DESCRIPTION)


int zisCheckUsername(const CrossMemoryServerName *serverName,
const char *userName,
ZISAuthServiceStatus *status);

int zisCheckUsernameAndPassword(const CrossMemoryServerName *serverName,
const char *userName, const char *password,
ZISAuthServiceStatus *status);
Expand Down
1 change: 1 addition & 0 deletions h/zis/services/auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ typedef struct AuthServiceParmList_tag {
#define ZIS_AUTH_SERVICE_PARMLIST_FC_ENTITY_CHECK 1
#define ZIS_AUTH_SERVICE_PARMLIST_FC_GET_ACCESS 2
#define ZIS_AUTH_SERVICE_PARMLIST_FC_GENERATE_TOKEN 3
#define ZIS_AUTH_SERVICE_PARMLIST_FC_VERIFY_USER 4
char userIDNullTerm[ZIS_AUTH_SERVICE_USER_ID_MAX_LENGTH + 1];
char passwordNullTerm[ZIS_AUTH_SERVICE_PASSWORD_MAX_LENGTH + 1];
/* up to 8 characters: */
Expand Down