Skip to content

Support Policy Builder Objects #341

Description

@dandend

Category

Other

Describe the feature you'd like to request

It would be helpful and less error prone for building policies on demand if there were native Java PolicyBuilder classes. For example:

Policy conditionalPolicy = PolicyBuilder.builder()
    .effect(Effect.PERMIT)
    .principal(Principal.parse("User::\"bob\""))
    .action(Action.parse("Action::\"write\""))
    .resource(Resource.parse("File::\"report.pdf\""))
    .condition(Condition.when(
        Expression.parse("principal.department == \"engineering\"")
    ))
    .build();

Describe alternatives you've considered

Today when I need to build Cedar policies on demand I either need to use string manipulation or create JSON objects that follow a specific format.

Additional context

Similar policy builder type classes for other policy languages: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/feature-iam-policy-builder.html

Is this something that you'd be interested in working on?

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions