-
Notifications
You must be signed in to change notification settings - Fork 3
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
To handle nested claims. #10
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,8 +88,32 @@ actions.set( | |
checkType(args.claims, "object"); | ||
}, | ||
function (args) { | ||
// Helper function to check equality of two objects | ||
function isEqual(obj1, obj2) { | ||
return JSON.stringify(obj1) === JSON.stringify(obj2); | ||
} | ||
// Helper function to check if an array contains an object | ||
function includes(array, obj) { | ||
return array.some((el) => JSON.stringify(el) === JSON.stringify(obj)); | ||
} | ||
|
||
|
||
const CLAIMS = { | ||
secureboot: "boolean", | ||
"x-ms-azurevm-os-provisioning": { | ||
"node-policy-identity": { | ||
"eventVersion": "number", | ||
"policyId": "string", | ||
"signer": "string", | ||
"svn": "number", | ||
}, | ||
"os-image-identity": { | ||
"diskId": "string", | ||
"eventVersion" : "number", | ||
"signer": "string", | ||
"svn": "number", | ||
} | ||
}, | ||
"x-ms-attestation-type": "string", | ||
"x-ms-azurevm-attestation-protocol-ver": "string", | ||
"x-ms-azurevm-attested-pcrs": "number[]", | ||
|
@@ -173,7 +197,7 @@ actions.set( | |
item.forEach((i) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the non-flattened model we should test if the key represents an object and than drill down in the object to check presence in CLAIMS. Way harder than using flattened claims. |
||
console.log(`[INFO] [scope=set_key_release_policy->add] KRP add ${type}=>Adding ${i} to ${key}`); | ||
// Only push if the element is not already in the array | ||
if (!items[key].includes(i)) { | ||
if (!includes(items[key],i)) { | ||
items[key].push(i); | ||
} | ||
}); | ||
|
@@ -303,7 +327,7 @@ actions.set( | |
if (items[key] !== undefined) { | ||
item.forEach((i) => { | ||
console.log(`[INFO] [scope=set_key_release_policy->remove] KRP remove ${type}=>Removing ${i} from ${key}`); | ||
items[key] = items[key].filter((value) => value !== i); | ||
items[key] = items[key].filter((value) => !isEqual(value, i)); | ||
if (items[key].length === 0) { | ||
delete items[key]; | ||
} | ||
|
@@ -318,7 +342,7 @@ actions.set( | |
} | ||
}); | ||
|
||
// Safe into KV | ||
// Save into KV | ||
console.log(`[INFO] [scope=set_key_release_policy->remove] KRP remove ${type}=>items: `, items); | ||
let jsonItems = JSON.stringify(items); | ||
console.log( | ||
|
@@ -427,4 +451,4 @@ actions.set( | |
} | ||
}, | ||
), | ||
); | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"actions": [ | ||
{ | ||
"name": "set_key_release_policy", | ||
"args": { | ||
"service": "tien-test", | ||
"type": "add", | ||
"claims": { | ||
"x-ms-azurevm-os-provisioning": { | ||
"node-policy-identity": { | ||
"eventVersion": "1", | ||
"policyId": "openai-whisper", | ||
"signer": "8fe6e7a314b8695b21710cebf0265e8d7bbaabde26f431c407faf16fcbd6b924" | ||
}, | ||
"os-image-identity": { | ||
"diskId": "singularity.ubuntu-22.04", | ||
"eventVersion" : "1", | ||
"signer": "f9cce5b7bdc2aaacfc4c78cb2b7515459aded8149287b74667bb2f178b0cf7b9" | ||
} | ||
} | ||
}, | ||
"gte": { | ||
"x-ms-azurevm-os-provisioning": { | ||
"node-policy-identity": { | ||
"svn": "1" | ||
}, | ||
"os-image-identity": { | ||
"svn": "1" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ export enum JwtIdentityProviderEnum { | |
MAA_NoSecureBootTyFu = "https://maanosecureboottestyfu.eus.attest.azure.net", | ||
MAA_NoSecureBootWeu = "https://accnosecurebootmaawesteu.weu.attest.azure.net", | ||
MAA_NoSecureBootEus = "https://accnosecurebootmaa.eus2.attest.azure.net", | ||
MAA_NoSecureBootInteTest = "https://confinfermaaeus2test.eus2.test.attest.azure.net", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have removed the necessity to add an issuer in code. This will not scale. I will sync my changes so we do no longer need this |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,15 @@ export class JwtValidator implements IValidatorService { | |
JwtIdentityProviderEnum.MAA_NoSecureBootEus, | ||
this.logContext | ||
); | ||
this.identityProviders.set( | ||
JwtIdentityProviderEnum.MAA_NoSecureBootIntgTest, | ||
new MsJwtProvider("JwtMaaProvider", this.logContext), | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
Logger.debug( | ||
"JwtIdentityProviderEnum.MAA_NoSecureBootIntgTest", | ||
JwtIdentityProviderEnum.MAA_NoSecureBootIntgTest, | ||
this.logContext | ||
); | ||
this.identityProviders.set( | ||
JwtIdentityProviderEnum.MS_AAD, | ||
new MsJwtProvider("JwtProvider", this.logContext), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are these claims tested when they appear in a KRP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this will eventually become very confusing. E.g. policyId is a claim that we want to compare on value while eventVersion is typically a gte check.
If we use flattened claims it will be clearer and we can easily check if these claim is allowed in CLAIMS:
"x-ms-azurevm-os-provisioning.node-policy-identity.eventVersion"
"x-ms-azurevm-os-provisioning.node-policy-identity.policyId"