-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #195 from microsoft/beejones/Add-LogContext-to-Logger
upstream of transparanty kms logger
- Loading branch information
Showing
22 changed files
with
607 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ ccf-app/ | |
nohup.out | ||
aad.env | ||
*.log | ||
temp*/ | ||
__pycache__/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
import { ccf } from "@microsoft/ccf-app/global"; | ||
import { Logger } from "../../utils/Logger"; | ||
import { Logger, LogContext } from "../../utils/Logger"; | ||
|
||
const validationPolicyMapName = "public:ccf.gov.policies.jwt_validation"; | ||
|
||
export class JwtValidationPolicyMap { | ||
public static read(issuer: string): { [key: string]: string } | undefined { | ||
public static read(issuer: string, logContextIn? : LogContext): { [key: string]: string } | undefined { | ||
const logContext = (logContextIn?.clone() || new LogContext()).appendScope("JwtValidationPolicyMap"); | ||
// For testing list all issuers | ||
const issuersMap = ccf.kv["public:ccf.gov.jwt.issuers"]; | ||
issuersMap.forEach((v, k) => { | ||
let issuer = ccf.bufToStr(k); | ||
let info = ccf.bufToJsonCompatible(v); | ||
Logger.debug(`Issuer: ${issuer}: ${JSON.stringify(info)}`); | ||
Logger.debug(`Issuer: ${issuer}: ${JSON.stringify(info)}`, logContext); | ||
}); | ||
|
||
const keyBuf = ccf.strToBuf(issuer); | ||
if (!ccf.kv[validationPolicyMapName].has(keyBuf)) { | ||
Logger.error(`No JWT validation Policy for issuer: ${issuer}`); | ||
Logger.error(`No JWT validation Policy for issuer: ${issuer}`, logContext); | ||
return undefined; | ||
} | ||
|
||
const policyBuf = ccf.kv[validationPolicyMapName].get(keyBuf); | ||
if (policyBuf === undefined) { | ||
Logger.error(`Policy buffer is undefined for issuer: ${issuer}`); | ||
Logger.error(`Policy buffer is undefined for issuer: ${issuer}`, logContext); | ||
return undefined; | ||
} | ||
|
||
const policy = ccf.bufToStr(policyBuf); | ||
Logger.info(`JWT validation: Policy: ${policy} for issuer: ${issuer}`); | ||
Logger.info(`JWT validation: Policy: ${policy} for issuer: ${issuer}`, logContext); | ||
return JSON.parse(policy); | ||
} | ||
} |
Oops, something went wrong.