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):
self.vp_token = request.values.get("vp_token")
# pv= self.vp_token.split(".")
# token = json.loads(base64.b64decode(pv[1]).decode())
pv = self.vp_token.split(".")
token = json.loads(base64.b64decode(pv[1]).decode())
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer WALLET_INX_EBSI_PLUGIN_TOKEN'
}
vcredential = token.get('vp', {}).get("verifiableCredential")
if not vcredential:
return
data = json.dumps({
"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"})
# if not self.code or not self.oidc: