Class OPAResponseContext

java.lang.Object
com.styra.opa.springboot.OPAResponseContext

public class OPAResponseContext extends Object
This class models the data to be returned from an OPA Spring Boot SDK policy under the context key. This corresponds to the Context object in the AuthZen spec, see: https://openid.github.io/authzen/#section-5.4
  • Constructor Details

    • OPAResponseContext

      public OPAResponseContext()
  • Method Details

    • getId

      public String getId()
    • setId

      public void setId(String newId)
    • getReasonAdmin

      public Map<String,String> getReasonAdmin()
    • setReasonAdmin

      public void setReasonAdmin(Map<String,String> newReasonAdmin)
    • getReasonUser

      public Map<String,String> getReasonUser()
    • setReasonUser

      public void setReasonUser(Map<String,String> newReasonUser)
    • setData

      public void setData(Map<String,Object> newData)
      The extra 'data' field allows for the OPA policy to pass back arbitrary structured data in addition to the expected reason information.
    • getData

      public Map<String,Object> getData()
    • getReasonForDecision

      public String getReasonForDecision(String searchKey)
      This method selects an appropriate reason to use for creating Spring authorization decisions. Currently, it will select the search key if it is present in the reason_user object, and if not it will select the key which sorts first from reason_user. It will not consider data in reason_admin.