Optionally specify capabilities list

master
Bob Mottram 2019-07-06 11:38:48 +01:00
parent c9d62e8361
commit 02bcea9ce1
1 changed files with 8 additions and 4 deletions

View File

@ -9,25 +9,29 @@ __status__ = "Production"
import os
from auth import createPassword
def sendCapabilitiesRequest(baseDir: str,httpPrefix: str,domain: str,requestedActor: str,inbox="write",objects="read") -> None:
def sendCapabilitiesRequest(baseDir: str,httpPrefix: str,domain: str, \
requestedActor: str, \
requestedCaps=["inbox:write","objects:read"]) -> None:
# This is sent to the capabilities endpoint /caps/new
# which could be instance wide or for a particular person
capId=createPassword(32)
capRequest = {
"id": httpPrefix+"://"+requestedDomain+"/caps/request/"+capId,
"type": "Request",
"capability": ["inbox:write","objects:read"],
"capability": requestedCaps,
"actor": requestedActor
}
#TODO
def sendCapabilitiesAccept(baseDir: str,httpPrefix: str,nickname: str,domain: str,acceptedActor: str,inbox="write",objects="read") -> None:
def sendCapabilitiesAccept(baseDir: str,httpPrefix: str,nickname: str,domain: str, \
acceptedActor: str, \
acceptedCaps=["inbox:write","objects:read"]) -> None:
# This gets returned to capabilities requester
capId=createPassword(32)
capAccept = {
"id": httpPrefix+"://"+domain+"/caps/"+capId,
"type": "Capability",
"capability": ["inbox:write","objects:read"],
"capability": acceptedCaps,
"scope": acceptedActor,
"actor": httpPrefix+"://"+domain
}