-
Notifications
You must be signed in to change notification settings - Fork 37
feat: persist extern AID metadata for alias-based lookup and rotation #418
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
Open
yeomjaeseung
wants to merge
2
commits into
WebOfTrust:main
Choose a base branch
from
yeomjaeseung:extern-prms
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+138
−27
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -42,7 +42,17 @@ class SaltyPrm: | |
| def __iter__(self): | ||
| return iter(asdict(self)) | ||
|
|
||
| @dataclass() | ||
| class ExternPrm: | ||
| """ | ||
| Extern prefix's parameters for referencing external key management | ||
| """ | ||
| pidx: int = 0 | ||
| extern_type: str = "" | ||
|
|
||
| def __iter__(self): | ||
| return iter(asdict(self)) | ||
|
|
||
| class RemoteKeeper(dbing.LMDBer): | ||
| """ | ||
| RemoteKeeper stores data for Salty or Randy Encrypted edge key generation. | ||
|
|
@@ -95,6 +105,7 @@ def __init__(self, headDirPath=None, perm=None, reopen=False, **kwa): | |
| self.nxts = None | ||
| self.prxs = None | ||
| self.gbls = None | ||
| self.eprms = None | ||
| if perm is None: | ||
| perm = self.Perm # defaults to restricted permissions for non temp | ||
|
|
||
|
|
@@ -136,6 +147,11 @@ def reopen(self, **kwa): | |
| subkey="pubs.", | ||
| schema=PubSet, | ||
| ) # public key set at pre.ridx | ||
| self.eprms = koming.Komer( | ||
| db=self, | ||
| subkey="eprms.", | ||
| schema=ExternPrm, | ||
| ) # New Extern Parameter | ||
| return self.opened | ||
|
|
||
|
|
||
|
|
@@ -444,5 +460,36 @@ class ExternKeeper: | |
| def __init__(self, rb: RemoteKeeper): | ||
| self.rb = rb | ||
|
|
||
| def incept(self, **kwargs): | ||
| pass | ||
| def incept(self, pre, pidx=0, extern_type="", **kwargs): | ||
| # Ignore unused kwargs | ||
| pp = Prefix(pidx=pidx, algo=Algos.extern) | ||
| if not self.rb.pres.put(pre, val=pp): | ||
| raise ValueError("Already incepted pre={}.".format(pre)) | ||
|
|
||
| ep = ExternPrm(pidx=pidx, extern_type=extern_type) | ||
| if not self.rb.eprms.put(pre, val=ep): | ||
| raise ValueError("Already incepted prm for pre={}.".format(pre)) | ||
|
|
||
| def rotate(self, pre, pidx=None, extern_type=None, **kwargs): | ||
| if (pp := self.rb.pres.get(pre)) is None or pp.algo != Algos.extern: | ||
| raise ValueError("Attempt to rotate nonexistent or invalid pre={}.".format(pre)) | ||
|
|
||
| if (ep := self.rb.eprms.get(pre)) is None: | ||
| ep = ExternPrm() | ||
|
|
||
| if pidx is not None: | ||
| ep.pidx = pidx | ||
| if extern_type is not None: | ||
| ep.extern_type = extern_type | ||
|
|
||
| if not self.rb.eprms.pin(pre, val=ep): | ||
| raise ValueError("Unable to rotate extern prms for pre={}.".format(pre)) | ||
|
|
||
| def params(self, pre): | ||
| if (pp := self.rb.pres.get(pre)) is None or pp.algo != Algos.extern: | ||
| raise ValueError("Attempt to load nonexistent or invalid pre={}.".format(pre)) | ||
| # Default extern params | ||
| if (ep := self.rb.eprms.get(pre)) is None: | ||
| return dict(extern=dict(extern_type="", pidx=pp.pidx)) | ||
|
Collaborator
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. For consistency, shouldn't we also |
||
|
|
||
| return dict(extern=asdict(ep)) | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This makes me wonder if there's actually value in storing any metadata at all with
eprms, or if it's enough to just populatepresand keep it more lightweight.