Skip to content

Commit

Permalink
Merge pull request #97 from velocitycareerlabs/VL-6178-verify-issuer.id
Browse files Browse the repository at this point in the history
verify issuer.id instead of iss
  • Loading branch information
michaelavoyan authored Feb 1, 2024
2 parents e194ace + e150a0f commit 00bbb96
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 160 deletions.
8 changes: 4 additions & 4 deletions VCL/VCL.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1892,7 +1892,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 121;
CURRENT_PROJECT_VERSION = 123;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 7DDDGP43MJ;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -1905,7 +1905,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.23.2;
MARKETING_VERSION = 1.23.3;
PRODUCT_BUNDLE_IDENTIFIER = io.velocitycareerlabs.VCL;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1922,7 +1922,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 121;
CURRENT_PROJECT_VERSION = 123;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 7DDDGP43MJ;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -1935,7 +1935,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.23.2;
MARKETING_VERSION = 1.23.3;
PRODUCT_BUNDLE_IDENTIFIER = io.velocitycareerlabs.VCL;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
16 changes: 10 additions & 6 deletions VCL/VCL/impl/data/utils/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class Utils {
var identifier: String? = nil
var stack = [[String: Any]]()
stack.append(jsonObject)

while (stack.isEmpty == false) {
let obj = stack.remove(at: stack.count - 1)

identifier = getPrimaryIdentifier(obj[primaryOrgProp!])
if (identifier != nil) {
break
}

obj.forEach { _, value in
if let valueDict = value as? [String: Any] {
stack.append(valueDict)
Expand All @@ -53,15 +53,19 @@ class Utils {
return credentialSubject as? String
}
return (credentialSubject as? [String: Any])?["identifier"] as? String
?? (credentialSubject as? [String: Any])?["id"] as? String
?? (credentialSubject as? [String: Any])?["id"] as? String
}

static func offersFromJsonArray(offersJsonArray: [[String: Any]]) -> [VCLOffer] {
var allOffers = [VCLOffer]()
offersJsonArray.forEach {
offersJsonArray.forEach {
allOffers.append(VCLOffer(payload: $0))
}
return allOffers
}


static func getCredentialIssuerId(jwtCredential: VCLJwt) -> String? {
let vc: [String: Any]? = jwtCredential.payload?["vc"] as? [String: Any]
return (vc?["issuer"] as? [String: Any])?["id"] as? String ?? vc?["issuer"] as? String
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ class CredentialIssuerVerifierImpl: CredentialIssuerVerifier {
let activeContext = (((completeContext[CodingKeys.KeyContext] as? [String: Any])?[credentialSubjectType] as? [String: Any]))?[CodingKeys.KeyContext] as? [String: Any] ?? completeContext
if let K = findKeyForPrimaryOrganizationValue(activeContext) {
if let did = Utils.getIdentifier(K, credentialSubject) {
if (jwtCredential.iss == did) {
// Comparing issuer.id instead of iss
// https://velocitycareerlabs.atlassian.net/browse/VL-6178?focusedCommentId=46933
// https://velocitycareerlabs.atlassian.net/browse/VL-6988
// if (jwtCredential.iss == did)
if (Utils.getCredentialIssuerId(jwtCredential: jwtCredential) == did) {
isCredentialVerified = true
completeConetxDispatcher.leave()
} else {
Expand Down
11 changes: 11 additions & 0 deletions VCL/VCLTests/infrastructure/resources/valid/CredentialMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 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XNzdWVyLmlkICE9IGlzc3Vlci5pZCDihpIgVFJVU1RFRF9JU1NVRVI6IEZBSUwiLCJpc3N1ZXIiOnsibmFtZSI6IlVuaXZlcnNhbCBJc3N1ZXIiLCJ0eXBlIjoiUHJvZmlsZSIsImlkIjoiVGVzdCJ9LCJjcml0ZXJpYSI6Imh0dHBzOi8vd3d3LmFldHNvZnQubmV0IiwidGFncyI6WyJzYW1wbGUtdGFnIl19LCJ0eXBlIjoiQmFkZ2UiLCJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vcWFsaWIudmVsb2NpdHluZXR3b3JrLmZvdW5kYXRpb24vY29udGV4dHMvbGF5ZXIxLXYxLjEuanNvbmxkLmpzb24iXX19LCJuYmYiOjE3MDMxNDQyMjEsImp0aSI6ImRpZDp2ZWxvY2l0eTp2MjoweDU3NTcyY2VhNTZmYjQwM2RjMTNjNjBjYmJjNjM3MTUwMGUxMTQ2NTY6MjM0NTc3OTQwMjM2MzYwOjc3NTYiLCJpc3MiOiJkaWQ6aW9uOkVpRFVJMGRhS3J0b0tIWHk0emFFeTZPM0k2Z01xeV95TXRJbDBPZTNtejk4VlEiLCJpYXQiOjE3MDMxNDQyMjF9.cExeY-Qu9WaYV9U5mWKDirdIMilVoPmixDgSkZsmOZCBt99vgfHtlPfyAW-Ez3HlcCwK0v5E8xjhV-IixR36NQ"


static let JwtCredentialsFromRegularIssuer =
"[\"\(JwtCredentialEducationDegreeRegistrationFromRegularIssuer)\", \"\(JwtCredentialEmploymentPastFromRegularIssuer)\"]"

Expand All @@ -49,5 +56,9 @@ class CredentialMocks {
static let JwtCredentialsWithoutSubject =
"[\"\(JwtCredEmailWithoutSubjectJwt)\", \"\(JwtCredPhoneWithoutSubjectJwt)\"]"

static let JwtCredentialsOpenBadgeValid = "[\"\(JwtCredentialOpenBadgeValid)\"]"

static let JwtCredentialsOpenBadgeInvalid = "[\"\(JwtCredentialOpenBadgeInvalid)\"]"

static let JwtEmptyCredentials = "[]"
}
Loading

0 comments on commit 00bbb96

Please sign in to comment.