Skip to content

Commit

Permalink
fix readme for policy callback
Browse files Browse the repository at this point in the history
Signed-off-by: sal rashid <salrashid123@gmail.com>
  • Loading branch information
salrashid123 committed Sep 30, 2024
1 parent 094ae98 commit 0ae84d4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -589,21 +589,23 @@ The way to do this is to implement an abstract class:
from cloud_auth_tpm.policy.policy import PolicyEval
```

which requires you to pass in a policy json on init and then impelment whatever you need to do in `policy_callback(ectx)`, eg:
which requires you to pass in a policy json on init and then impelment whatever you need to do in `policy_callback(ectx: ESAPI, handle: ESYS_TR):`, eg:


```python
class PolicyEval(object, metaclass=ABCMeta):
def __init__(self, policy: dict[str, any] , debug: bool):

@abstractmethod
def policy_callback(self, ectx: ESAPI):
def policy_callback(self, ectx: ESAPI, handle: ESYS_TR):
pass
```

so for the built-in policy see [cloud_auth_tpm/policy/pcr.py](cloud_auth_tpm/policy/pcr.py).
where `ectx` is just the TPM context and `handle` is what key used for session encryption.

Then to use it, fist import the policy (in this example, its the default `PCRPolicy`), supply it with the json format of the policy and specify it when invoking credentials.
For a built-in policy see [cloud_auth_tpm/policy/pcr.py](cloud_auth_tpm/policy/pcr.py).

To use a custom policy, fist import a class (in this example, its the default `PCRPolicy`), supply it with the json format of the policy and specify it when invoking credentials.

eg, with

Expand Down

0 comments on commit 0ae84d4

Please sign in to comment.