diff --git a/internal/regofunc/ocm.go b/internal/regofunc/ocm.go index 0145bac5517f74a4eea8707845e92aa33c638e83..b32f992213bc8a4fe6f35b142deb9a26d48cef65 100644 --- a/internal/regofunc/ocm.go +++ b/internal/regofunc/ocm.go @@ -74,8 +74,15 @@ func (of *OcmFuncs) GetLoginProofResult() (*rego.Function, rego.Builtin1) { return nil, err } + claims := map[string]interface{}{} + for _, cred := range res.Data.Data { + for cName, cValue := range cred.Claims { + claims[cName] = cValue + } + } + var val ast.Value - val, err = ast.InterfaceToValue(res.Data.Claims) + val, err = ast.InterfaceToValue(claims) if err != nil { return nil, err } diff --git a/internal/regofunc/ocm_test.go b/internal/regofunc/ocm_test.go index 63d022e54ab9102a2690357aa73be72285136cbc..26de0b0487ab6f794a02b2bfbe8857f24ed6e042 100644 --- a/internal/regofunc/ocm_test.go +++ b/internal/regofunc/ocm_test.go @@ -70,12 +70,20 @@ func TestGetLoginProofResult(t *testing.T) { expected := `{"family_name":"Doe","name":"John"}` ocmResponse := `{ "statusCode": 200, - "message": "Proof presentation fetch successfully", "data": { - "credentialSubject": { - "name":"John", - "family_name":"Doe" - } + "state": "done", + "data": [ + { + "credentialSubject": { + "family_name":"Doe" + } + }, + { + "credentialSubject": { + "name":"John" + } + } + ] } }`