get roles from credential

This commit is contained in:
Cayo Puigdefabregas 2023-12-11 21:30:56 +01:00
parent 543aad813d
commit fc7d7b4549
1 changed files with 17 additions and 4 deletions

View File

@ -223,17 +223,30 @@ class AllowCodeOidc4vpView(GenericMixin):
def dispatch_request(self): def dispatch_request(self):
self.vp_token = request.values.get("vp_token") self.vp_token = request.values.get("vp_token")
# pv= self.vp_token.split(".") pv = self.vp_token.split(".")
# token = json.loads(base64.b64decode(pv[1]).decode()) token = json.loads(base64.b64decode(pv[1]).decode())
headers = { headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': f'Bearer WALLET_INX_EBSI_PLUGIN_TOKEN' 'Authorization': f'Bearer WALLET_INX_EBSI_PLUGIN_TOKEN'
} }
vcredential = token.get('vp', {}).get("verifiableCredential")
if not vcredential:
return
data = json.dumps({ data = json.dumps({
"type": "VerificationRequest", "type": "VerificationRequest",
"jwtCredential": self.vp_token "jwtCredential": vcredential
}) })
result = requests.post(WALLET_INX_EBSI_PLUGIN_URL, headers=headers, json=data) result = requests.post(WALLET_INX_EBSI_PLUGIN_URL, headers=headers, data=data)
if result.status_code != 200:
return
vps = json.loads(result.text)
if not vps.get('verified'):
return
roles = vps['credential']['credentialSubject'].get('role')
if not roles:
return
return jsonify({"result": "ok"}) return jsonify({"result": "ok"})
# if not self.code or not self.oidc: # if not self.code or not self.oidc: