hexa-org / policy-opa

Supports integration of Hexa IDQL Policy into OPA environments
Apache License 2.0
3 stars 1 forks source link

Update Subject Info to encoded member values #3

Closed independentid closed 5 months ago

independentid commented 6 months ago

OPA Rego currently assumes SubjectInfo has "type", "provider" and other configuration variables.

Current IDQL subjectInfo just has "members: []string". This means we have to use an encoded member value. E.g.

"members" : ["type:jwt:provider:myTestIDP:iss:testIssuer:aud:testAudience:role:abc","BaSicBob"]

In OPA we want to express multiple authentication types including Basic and JWT. In the case of JWT we need to include params like issuer and audience.

The other issue is how to express specific users within a type. Do we prefix every user with type:jwt:.... or break the rules a bit and express as above where "basicbob" is allowed if authenticated via JWT.

Note: this is a quasi bug as current members won't be handled properly without changes to OPA provider and/or rego.

independentid commented 6 months ago

In order to keep the semantics of members simple, recommend moving the type logic down to conditions since most apps rarely accept multiple types (e.g. basic and jwt) at the same time. Based on this, what subjects does is match the authenticated subject quickly to decide whether to process extended authentication infomation that may be part of conditions. Recommend subjects have the following variations:

To test if a subject was authenticated by JWT with a particular issuer and aud (above example):

subject.type eq "jwt" and subject.iss eq "testIssuer" and "testAudience" in subject.aud