Skip to content

Commit 6fd5d70

Browse files
Merge pull request #26 from consumer-reports-innovation-lab/091
verify key uses base64 encoding, version to 091
2 parents 8de4c07 + 0bd6f17 commit 6fd5d70

File tree

10 files changed

+35
-45
lines changed

10 files changed

+35
-45
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# OSIRAA - Open Source Implementers’ Reference Authorized Agent
22

3-
Version 0.9.0 - Updated September 2023
3+
Version 0.9.1 - Updated December 2023
44

55
## OSIRAA is a live and available for use at [https://osiraa.datarightsprotocol.org/](https://osiraa.datarightsprotocol.org/).
66

77
## How to Use this App:
88
OSIRAA (Open Source Implementers’ Reference Authorized Agent) is a test suite designed to simulate the role of an Authorized Agent in a Data Rights Protocol (DRP) environment. The application tests for the availability, correctness and completeness of API endpoints of a Privacy Infrastructure Provider (PIP) or Covered Business (CB) partner application. See <a href="https://github.com/consumer-reports-digital-lab/data-rights-protocol/blob/main/data-rights-protocol.md" target="blank">https://github.com/consumer-reports-digital-lab/data-rights-protocol/blob/main/data-rights-protocol.md</a> for more info on DRP system roles and API specification.
99

1010
## Admin Tool
11-
A user may model a Privacy Infrastructure Provider (PIP) or Covered Business (CB) in the Admin Tool, along with any number of users. This is a standard Python app, so you must first create an admin superuser before you can administer data configurations. For version 0.9, the Discovery Endpoint for a Covered Business has been depricated; it has been replaced by a Service Directory. The Service Directory holds discoverable information for all DPR impelementers in a common place. This information is periodically queried and the database automatically updated.
11+
A user may model a Privacy Infrastructure Provider (PIP) or Covered Business (CB) in the Admin Tool, along with any number of users. This is a standard Python app, so you must first create an admin superuser before you can administer data configurations. For version 0.9.1, the Discovery Endpoint for a Covered Business has been depricated; it has been replaced by a Service Directory. The Service Directory holds discoverable information for all DPR impelementers in a common place. This information is periodically queried and the database automatically updated.
1212

1313
## Cert Tests Definitions
1414
The Data Rights Protocol is centered on a set of API calls between an Authorized Agent (AA) and a Privacy Infrastructure Provider or Covered Business, on behalf of a User exercising his or her data rights.

drp_aa_mvp/data_rights_request/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
"""
4141
class RequestMetaData():
42-
version = "0.9"
42+
version = "0.9.1"
4343
"""
4444

4545
IN_PROGRESS = 'in_progress'

drp_aa_mvp/data_rights_request/templates/data_rights_request/data_rights.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.8",
2+
"version": "0.9.1",
33
"api_base": "https://example.com/data-rights",
44
"actions": ["sale:opt-out", "sale:opt-in", "access", "deletion"],
55
"user_relationships": [ ]

drp_aa_mvp/data_rights_request/templates/drp_aa_mvp/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<h2>OSIRAA - Open Source Implementer's Reference Authorized Agent</h2>
33
<br/>
44

5-
<h3>Version 0.9.0 - Updated September 2023</h3>
5+
<h3>Version 0.9.1 - Updated December 2023</h3>
66

77
<p><b>How to Use this App:</b><br/>
88
OSIRAA (Open Source Implementer's Reference Authorized Agent) is test suite designed to simulate the role of an Authorized Agent in a Digital Rights Protocol (DRP) environment. The application tests for the availability, correctness and completeness of API endpoints of a Privacy Infrastructure Provider (PIP) or Covered Business (CB) partner application. See <a href="https://github.com/consumer-reports-digital-lab/data-rights-protocol/blob/main/data-rights-protocol.md" target="blank">https://github.com/consumer-reports-digital-lab/data-rights-protocol/blob/main/data-rights-protocol.md</a> for more info on DRP system roles and API specification.</p>
99

1010
<p><b><a href="/admin/">Admin Tool</a></b><br/>
11-
A user may model a PIP or Covered Business in the Admin Tool, along with any number of users. This is a standard Python app, so you must first create an admin superuser in the usual way before you can administer data configurations. For version 0.9, the Discovery Endpoint for a Covered Business has been depricated; it has been replaced by a Service Directory. The Service Directory holds discoverable information for all DPR impelementers in a common place. This information is periodically queried and the database automatically updated.
11+
A user may model a PIP or Covered Business in the Admin Tool, along with any number of users. This is a standard Python app, so you must first create an admin superuser in the usual way before you can administer data configurations. For version 0.9.1, the Discovery Endpoint for a Covered Business has been depricated; it has been replaced by a Service Directory. The Service Directory holds discoverable information for all DPR impelementers in a common place. This information is periodically queried and the database automatically updated.
1212
</p>
1313

1414
<p><a href="/reporting/"><b>Cert Tests Definitions</b></a><br/>

drp_aa_mvp/data_rights_request/views.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from django.http import HttpResponse, HttpResponseRedirect
1818
from django.shortcuts import render
1919
from nacl import signing
20-
from nacl.encoding import HexEncoder
20+
from nacl.encoding import Base64Encoder
2121
from nacl.public import PrivateKey
2222
from reporting.views import (test_agent_information_endpoint, test_exercise_endpoint, #test_discovery_endpoint,
2323
test_status_endpoint, test_revoked_endpoint, test_pairwise_key_setup_endpoint)
@@ -95,7 +95,7 @@
9595
"""
9696

9797
# todo: these keys actually should be generated offline before we start using the app
98-
# and get them from the v0.9 service directory which will be a part of this dhango app, along with OSIRPIP
98+
# and get them from the v0.9.1 service directory which will be a part of this dhango app, along with OSIRPIP
9999
# for now we'll generate the keys one-time only
100100
def load_pynacl_keys() -> Tuple[signing.SigningKey, signing.VerifyKey]:
101101
path = os.environ.get("OSIRAA_KEY_FILE", "./keys.json")
@@ -105,23 +105,23 @@ def load_pynacl_keys() -> Tuple[signing.SigningKey, signing.VerifyKey]:
105105
signing_key = signing.SigningKey.generate()
106106
verify_key = signing_key.verify_key
107107
json.dump({
108-
"signing_key": signing_key.encode(encoder=HexEncoder).decode(),
109-
"verify_key": verify_key.encode(encoder=HexEncoder).decode()
108+
"signing_key": signing_key.encode(encoder=Base64Encoder).decode(),
109+
"verify_key": verify_key.encode(encoder=Base64Encoder).decode()
110110
}, f)
111111

112112
with open(path, "r") as f:
113113
jason = json.load(f)
114-
return (signing.SigningKey(jason["signing_key"], encoder=HexEncoder),
115-
signing.VerifyKey(jason["verify_key"], encoder=HexEncoder))
114+
return (signing.SigningKey(jason["signing_key"], encoder=Base64Encoder),
115+
signing.VerifyKey(jason["verify_key"], encoder=Base64Encoder))
116116

117117

118118
signing_key, verify_key = load_pynacl_keys()
119119

120120

121121
# the public key and signing key as b64 strings
122-
signing_key_hex = signing_key.encode(encoder=HexEncoder) # remains secret, never shared, but remains with AA model
123-
verify_key_hex = verify_key.encode(encoder=HexEncoder) # we're going to store hex encoded verify key in the service directory
124-
logger.debug(f"verify_key is {verify_key_hex}")
122+
signing_key_b64 = signing_key.encode(encoder=Base64Encoder) # remains secret, never shared, but remains with AA model
123+
verify_key_b64 = verify_key.encode(encoder=Base64Encoder) # we're going to store base64 encoded verify key in the service directory
124+
logger.debug(f"verify_key is {verify_key_b64}")
125125

126126
selected_covered_biz: Optional[CoveredBusiness] = None
127127

@@ -205,7 +205,7 @@ def select_covered_business(request):
205205
return render(request, 'data_rights_request/index.html', context)
206206

207207

208-
# depricated for 0.9, replace with a call to the service directory
208+
# depricated for 0.9.1, replace with a call to the service directory
209209
"""
210210
def send_request_discover_data_rights(request):
211211
covered_biz_id = request.POST.get('sel_covered_biz_id')
@@ -577,9 +577,9 @@ def get_request_actions_form_display (covered_biz):
577577

578578
def sign_request(signing_key, request_obj):
579579
signed_obj = signing_key.sign(json.dumps(request_obj).encode())
580-
bencoded = base64.b64encode(signed_obj)
580+
b64encoded = base64.b64encode(signed_obj)
581581

582-
return bencoded
582+
return b64encoded
583583

584584

585585
def create_setup_pairwise_key_request_json(covered_biz_id):
@@ -664,7 +664,7 @@ def create_exercise_request_json(user_identity, covered_biz, request_action, cov
664664
"issued-at": str(issued_time),
665665

666666
# 2
667-
"drp.version": "0.9",
667+
"drp.version": "0.9.1",
668668
"exercise": request_action,
669669
"regime": covered_regime,
670670
"relationships": [],

drp_aa_mvp/drp_pip/migrations/0001_initial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Migration(migrations.Migration):
2121
('logo', models.ImageField(blank=True, upload_to='company-logos', verbose_name='Logo Image')),
2222
('logo_thumbnail', models.ImageField(blank=True, upload_to='company-logos/thumbnails')),
2323
('subtitle_description', models.TextField(blank=True)),
24-
('verify_key', models.TextField(verbose_name='Hex encoded key to verify signed requests')),
24+
('verify_key', models.TextField(verbose_name='Base64 encoded key to verify signed requests')),
2525
],
2626
),
2727
]

drp_aa_mvp/drp_pip/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AuthorizedAgent(models.Model):
2424
logo_thumbnail = models.ImageField(upload_to='company-logos/thumbnails', blank=True)
2525
subtitle_description = models.TextField(blank=True)
2626

27-
verify_key = models.TextField('Hex encoded key to verify signed requests')
27+
verify_key = models.TextField('Base64 encoded key to verify signed requests')
2828
bearer_token = models.TextField('pair-wise token between AA and CB', blank=True)
2929

3030
def __str__(self):

drp_aa_mvp/drp_pip/views.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from django.views.decorators.csrf import csrf_exempt
1111
from django.views.decorators.http import require_http_methods
1212
from django.http import JsonResponse, HttpResponse, HttpRequest
13-
from nacl.encoding import HexEncoder
13+
from nacl.encoding import Base64Encoder
1414
from nacl.signing import VerifyKey
1515
from nacl.utils import random
1616
import nacl.exceptions
@@ -29,16 +29,6 @@
2929

3030
OSIRAA_PIP_CB_ID = os.environ.get("OSIRAA_PIP_CB_ID", "osiraa-local-001")
3131

32-
# todo: @RRIX - this has been depricated for 0.9 and can be removed, correct?
33-
"""
34-
@csrf_exempt
35-
def static_discovery(request):
36-
return JsonResponse({
37-
"version": "0.8",
38-
"actions": ["sale:opt-out", "sale:opt-in", "access", "deletion"],
39-
"api_base": f"{request.scheme}://{request.get_host()}/pip/",
40-
})
41-
"""
4232

4333
"""
4434
Privacy Infrastructure Providers MUST validate the message in this order:
@@ -76,7 +66,7 @@ def register_agent(request, aa_id: str):
7666
return HttpResponse(status=403)
7767

7868
# make a token and persist it...
79-
agent.bearer_token = HexEncoder.encode(random(size=64)).decode()
69+
agent.bearer_token = Base64Encoder.encode(random(size=64)).decode()
8070
try:
8171
agent.save()
8272
return JsonResponse({
@@ -207,10 +197,10 @@ def validate_message_to_agent(agent: AuthorizedAgent, request: HttpRequest) -> d
207197
now = arrow.get()
208198

209199
aa_id = agent.aa_id
210-
verify_key_hex = agent.verify_key
211-
verify_key = VerifyKey(verify_key_hex, encoder=HexEncoder)
200+
verify_key_b64 = agent.verify_key
201+
verify_key = VerifyKey(verify_key_b64, encoder=Base64Encoder)
212202

213-
logger.debug(f"vk is {verify_key_hex}")
203+
logger.debug(f"vk is {verify_key_b64}")
214204
logger.debug(f"agent is {aa_id}")
215205

216206
decoded = base64.b64decode(request.body)

drp_aa_mvp/reporting/templates/reporting/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ <h2>OSIRAA - Open Source Implementer's Reference Authorized Agent</h2>
44

55
<h3>DRP Cert Test Suite</h3>
66

7-
<p>Version 0.9.0 - Updated Septmeber 2023</p>
7+
<p>Version 0.9.1 - Updated December 2023</p>
88

99
<p>See also <a href="https://github.com/consumer-reports-digital-lab/data-rights-protocol/blob/main/data-rights-protocol.md" target="blank">https://github.com/consumer-reports-digital-lab/data-rights-protocol/blob/main/data-rights-protocol.md</a></p>
1010

1111
<br/>
1212

13-
<!---“Data Rights Discovery” endpoint is depricated in 0.9 -->
13+
<!-- “Data Rights Discovery” endpoint is depricated in 0.9.1 -->
1414
<!--
1515
<p><b>1. &nbsp; GET /.well-known/data-rights.json (“Data Rights Discovery” endpoint)</b></p>
1616
<ul>
1717
<li>Covered Business's domain SHOULD have a /.well-known/data-rights.json</li>
1818
<li>Discovery Endpoint MUST be valid JSON</li>
19-
<li>Discovery Endpoint MUST contain a version field (currently 0.8)</li>
19+
<li>Discovery Endpoint MUST contain a version field (currently 0.9.1)</li>
2020
<li>Discovery Endpoint MUST provide a field “api_base”
2121
<ul>
2222
<li>“api_base” url MUST be a well-formed url</li>
@@ -46,7 +46,7 @@ <h3>DRP Cert Test Suite</h3>
4646
<br/>
4747

4848
<span>The second grouping contains data about the Data Rights Request</span>
49-
<li>“drp.version” - a string referencing the current protocol version "0.9"</li>
49+
<li>“drp.version” - a string referencing the current protocol version "0.9.1"</li>
5050
<li>“exercise” - string specifying the Rights Action: [ access | deletion | sale:opt_out | sale:opt_in | access:categories | access:specific ]</li>
5151
<li>“regime” (optional) - a string specifying the legal regime under which the Data Request is being taken: [ ccpa | voluntary ]</li>
5252
<li>“relationships” (optional) - a list of string 'hints' for the Covered Business</li>

drp_aa_mvp/reporting/views.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def index(request):
1414

1515

1616
#---------------------------------------------------------------------------------------------------------------------#
17-
# test_discovery_endpoint - depricated for 0.9
17+
# test_discovery_endpoint - depricated for 0.9.1
1818

1919
"""
2020
def test_discovery_endpoint(request_url, responses):
@@ -24,7 +24,7 @@ def test_discovery_endpoint(request_url, responses):
2424
1. GET /.well-known/data-rights.json ("Data Rights Discovery" endpoint)
2525
- Covered Business's domain SHOULD have a /.well-known/data-rights.json
2626
- Discovery Endpoint MUST be valid JSON
27-
- Discovery Endpoint MUST contain a version field (currently 0.8)
27+
- Discovery Endpoint MUST contain a version field (currently 0.9.1)
2828
- Discovery Endpoint MUST provide a field “api_base”
2929
- “api_base” url MUST be a well-formed url
3030
- “api_base” url MUST be valid for subsequent calls
@@ -62,7 +62,7 @@ def test_discovery_endpoint(request_url, responses):
6262
is_valid_json = test_is_valid_json(response)
6363
test_results.append({'name': 'Is valid json', 'result': is_valid_json})
6464
65-
# test Discovery Endpoint MUST contain a version field (currently 0.8)
65+
# test Discovery Endpoint MUST contain a version field (currently 0.9.1)
6666
contains_version_field = test_contains_version_field(response)
6767
test_results.append({'name': 'Contains version field', 'result': contains_version_field})
6868
@@ -117,7 +117,7 @@ def test_contains_version_field(response):
117117
response_json = json.loads(response.text)
118118
except ValueError as e:
119119
return False
120-
return 'version' in response_json and response_json['version'] == '0.8'
120+
return 'version' in response_json and response_json['version'] == '0.9.1'
121121
122122
def test_contains_api_base(response):
123123
try:
@@ -192,7 +192,7 @@ def test_exercise_endpoint(request_json, response):
192192
- “business-id” - a string identifying the Covered Business which the request is being sent to
193193
- “expires-at” - an ISO 8601-encoded timestamp expressing when the request should no longer be considered viable
194194
- “issued-at” - an ISO 8601-encoded timestamp expressing when the request was created.
195-
- “drp.version” - a string referencing the current protocol version "0.9"
195+
- “drp.version” - a string referencing the current protocol version "0.9.1"
196196
- “exercise” - string specifying the Rights Action: [ access | deletion | sale:opt_out | sale:opt_in | access:categories | access:specific ]
197197
- “regime” (optional) - a string specifying the legal regime under which the Data Request is being taken: [ ccpa | voluntary ]
198198
- “relationships” (optional) - a list of string 'hints' for the Covered Business

0 commit comments

Comments
 (0)