Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZKAPAuthorizer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Administrator
ZKAPAuthorizer
Commits
d66a2fe7
Unverified
Commit
d66a2fe7
authored
4 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Some logging to do with call_with_passes
parent
503c8613
No related branches found
Branches containing commit
No related tags found
1 merge request
!153
Rescue some passes
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/_zkapauthorizer/_plugin.py
+4
-23
4 additions, 23 deletions
src/_zkapauthorizer/_plugin.py
src/_zkapauthorizer/_storage_client.py
+26
-7
26 additions, 7 deletions
src/_zkapauthorizer/_storage_client.py
src/_zkapauthorizer/eliot.py
+58
-0
58 additions, 0 deletions
src/_zkapauthorizer/eliot.py
with
88 additions
and
30 deletions
src/_zkapauthorizer/_plugin.py
+
4
−
23
View file @
d66a2fe7
...
@@ -45,11 +45,6 @@ from twisted.internet.defer import (
...
@@ -45,11 +45,6 @@ from twisted.internet.defer import (
succeed
,
succeed
,
)
)
from
eliot
import
(
MessageType
,
Field
,
)
from
allmydata.interfaces
import
(
from
allmydata.interfaces
import
(
IFoolscapStoragePlugin
,
IFoolscapStoragePlugin
,
IAnnounceableStorageServer
,
IAnnounceableStorageServer
,
...
@@ -69,6 +64,10 @@ from .api import (
...
@@ -69,6 +64,10 @@ from .api import (
ZKAPAuthorizerStorageClient
,
ZKAPAuthorizerStorageClient
,
)
)
from
.eliot
import
(
GET_PASSES
,
)
from
.model
import
(
from
.model
import
(
VoucherStore
,
VoucherStore
,
)
)
...
@@ -91,24 +90,6 @@ from .lease_maintenance import (
...
@@ -91,24 +90,6 @@ from .lease_maintenance import (
_log
=
Logger
()
_log
=
Logger
()
PRIVACYPASS_MESSAGE
=
Field
(
u
"
message
"
,
unicode
,
u
"
The PrivacyPass request-binding data associated with a pass.
"
,
)
PASS_COUNT
=
Field
(
u
"
count
"
,
int
,
u
"
A number of passes.
"
,
)
GET_PASSES
=
MessageType
(
u
"
zkapauthorizer:get-passes
"
,
[
PRIVACYPASS_MESSAGE
,
PASS_COUNT
],
u
"
Passes are being spent.
"
,
)
@implementer
(
IAnnounceableStorageServer
)
@implementer
(
IAnnounceableStorageServer
)
@attr.s
@attr.s
class
AnnounceableStorageServer
(
object
):
class
AnnounceableStorageServer
(
object
):
...
...
This diff is collapsed.
Click to expand it.
src/_zkapauthorizer/_storage_client.py
+
26
−
7
View file @
d66a2fe7
...
@@ -20,6 +20,10 @@ This is the client part of a storage access protocol. The server part is
...
@@ -20,6 +20,10 @@ This is the client part of a storage access protocol. The server part is
implemented in ``_storage_server.py``.
implemented in ``_storage_server.py``.
"""
"""
from
__future__
import
(
absolute_import
,
)
from
functools
import
(
from
functools
import
(
partial
,
partial
,
wraps
,
wraps
,
...
@@ -30,6 +34,11 @@ import attr
...
@@ -30,6 +34,11 @@ import attr
from
zope.interface
import
(
from
zope.interface
import
(
implementer
,
implementer
,
)
)
from
eliot.twisted
import
(
DeferredContext
,
)
from
twisted.internet.defer
import
(
from
twisted.internet.defer
import
(
inlineCallbacks
,
inlineCallbacks
,
returnValue
,
returnValue
,
...
@@ -39,6 +48,11 @@ from allmydata.interfaces import (
...
@@ -39,6 +48,11 @@ from allmydata.interfaces import (
IStorageServer
,
IStorageServer
,
)
)
from
.eliot
import
(
SIGNATURE_CHECK_FAILED
,
CALL_WITH_PASSES
,
)
from
.storage_common
import
(
from
.storage_common
import
(
MorePassesRequired
,
MorePassesRequired
,
pass_value_attribute
,
pass_value_attribute
,
...
@@ -51,7 +65,6 @@ from .storage_common import (
...
@@ -51,7 +65,6 @@ from .storage_common import (
get_required_new_passes_for_mutable_write
,
get_required_new_passes_for_mutable_write
,
)
)
class
IncorrectStorageServerReference
(
Exception
):
class
IncorrectStorageServerReference
(
Exception
):
"""
"""
A Foolscap remote object which should reference a ZKAPAuthorizer storage
A Foolscap remote object which should reference a ZKAPAuthorizer storage
...
@@ -93,7 +106,8 @@ def call_with_passes(method, num_passes, get_passes):
...
@@ -93,7 +106,8 @@ def call_with_passes(method, num_passes, get_passes):
"""
"""
def
get_more_passes
(
reason
):
def
get_more_passes
(
reason
):
reason
.
trap
(
MorePassesRequired
)
reason
.
trap
(
MorePassesRequired
)
if
len
(
reason
.
value
.
signature_check_failed
)
==
0
:
num_failed
=
len
(
reason
.
value
.
signature_check_failed
)
if
num_failed
==
0
:
# If no signature checks failed then the call just didn't supply
# If no signature checks failed then the call just didn't supply
# enough passes. The exception tells us how many passes we should
# enough passes. The exception tells us how many passes we should
# spend so we could try again with that number of passes but for
# spend so we could try again with that number of passes but for
...
@@ -102,18 +116,23 @@ def call_with_passes(method, num_passes, get_passes):
...
@@ -102,18 +116,23 @@ def call_with_passes(method, num_passes, get_passes):
# this case is somewhat suspicious. Err on the side of lack of
# this case is somewhat suspicious. Err on the side of lack of
# service instead of burning extra passes.
# service instead of burning extra passes.
return
reason
return
reason
new_passes
=
get_passes
(
len
(
reason
.
value
.
signature_check_failed
))
SIGNATURE_CHECK_FAILED
.
log
(
count
=
num_failed
)
new_passes
=
get_passes
(
num_failed
)
for
idx
,
new_pass
in
zip
(
reason
.
value
.
signature_check_failed
,
new_passes
):
for
idx
,
new_pass
in
zip
(
reason
.
value
.
signature_check_failed
,
new_passes
):
passes
[
idx
]
=
new_pass
passes
[
idx
]
=
new_pass
return
go
(
passes
)
return
go
(
passes
)
def
go
(
passes
):
def
go
(
passes
):
d
=
maybeDeferred
(
method
,
passes
)
# Capture the Eliot context for the errback.
d
=
DeferredContext
(
maybeDeferred
(
method
,
passes
))
d
.
addErrback
(
get_more_passes
)
d
.
addErrback
(
get_more_passes
)
return
d
# Return the underlying Deferred without finishing the action.
return
d
.
result
passes
=
get_passes
(
num_passes
)
with
CALL_WITH_PASSES
(
count
=
num_passes
).
context
():
return
go
(
passes
)
passes
=
get_passes
(
num_passes
)
# Finish the Eliot action when this is done.
return
DeferredContext
(
go
(
passes
)).
addActionFinish
()
def
with_rref
(
f
):
def
with_rref
(
f
):
...
...
This diff is collapsed.
Click to expand it.
src/_zkapauthorizer/eliot.py
0 → 100644
+
58
−
0
View file @
d66a2fe7
# Copyright 2020 PrivateStorage.io, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Eliot field, message, and action definitions for ZKAPAuthorizer.
"""
from
__future__
import
(
absolute_import
,
)
from
eliot
import
(
Field
,
MessageType
,
ActionType
,
)
PRIVACYPASS_MESSAGE
=
Field
(
u
"
message
"
,
unicode
,
u
"
The PrivacyPass request-binding data associated with a pass.
"
,
)
PASS_COUNT
=
Field
(
u
"
count
"
,
int
,
u
"
A number of passes.
"
,
)
GET_PASSES
=
MessageType
(
u
"
zkapauthorizer:get-passes
"
,
[
PRIVACYPASS_MESSAGE
,
PASS_COUNT
],
u
"
Passes are being spent.
"
,
)
SIGNATURE_CHECK_FAILED
=
MessageType
(
u
"
zkapauthorizer:storage-client:signature-check-failed
"
,
[
PASS_COUNT
],
u
"
Some passes the client tried to use were rejected for having invalid signatures.
"
,
)
CALL_WITH_PASSES
=
ActionType
(
u
"
zkapauthorizer:storage-client:call-with-passes
"
,
[
PASS_COUNT
],
[],
u
"
A storage operation is being started which may spend some passes.
"
,
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment