Skip to content

Commit

Permalink
feat: add ABAC support
Browse files Browse the repository at this point in the history
  • Loading branch information
booniepepper committed Dec 6, 2023
1 parent 6d6a615 commit 58c2993
Show file tree
Hide file tree
Showing 118 changed files with 3,615 additions and 503 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "monthly"
groups:
dependencies:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
dependencies:
patterns:
- "*"
39 changes: 36 additions & 3 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.github/CODEOWNERS
.github/ISSUE_TEMPLATE/bug_report.md
.github/ISSUE_TEMPLATE/feature_request.md
.github/dependabot.yaml
.github/workflows/main.yml
.github/workflows/semgrep.yaml
.gitignore
Expand All @@ -17,14 +18,18 @@ docs/Any.md
docs/Assertion.md
docs/AuthorizationModel.md
docs/CheckRequest.md
docs/CheckRequestTupleKey.md
docs/CheckResponse.md
docs/Computed.md
docs/Condition.md
docs/ConditionParamTypeRef.md
docs/ContextualTupleKeys.md
docs/CreateStoreRequest.md
docs/CreateStoreResponse.md
docs/Difference.md
docs/ErrorCode.md
docs/ExpandRequest.md
docs/ExpandRequestTupleKey.md
docs/ExpandResponse.md
docs/GetStoreResponse.md
docs/InternalErrorCode.md
Expand All @@ -37,6 +42,7 @@ docs/Metadata.md
docs/Node.md
docs/Nodes.md
docs/NotFoundErrorCode.md
docs/NullValue.md
docs/ObjectRelation.md
docs/OpenFgaApi.md
docs/PathUnknownErrorMessageResponse.md
Expand All @@ -45,18 +51,21 @@ docs/ReadAuthorizationModelResponse.md
docs/ReadAuthorizationModelsResponse.md
docs/ReadChangesResponse.md
docs/ReadRequest.md
docs/ReadRequestTupleKey.md
docs/ReadResponse.md
docs/RelationMetadata.md
docs/RelationReference.md
docs/RelationshipCondition.md
docs/Status.md
docs/Store.md
docs/Tuple.md
docs/TupleChange.md
docs/TupleKey.md
docs/TupleKeys.md
docs/TupleKeyWithoutCondition.md
docs/TupleOperation.md
docs/TupleToUserset.md
docs/TypeDefinition.md
docs/TypeName.md
docs/Users.md
docs/Userset.md
docs/UsersetTree.md
Expand All @@ -68,6 +77,8 @@ docs/WriteAssertionsRequest.md
docs/WriteAuthorizationModelRequest.md
docs/WriteAuthorizationModelResponse.md
docs/WriteRequest.md
docs/WriteRequestDeletes.md
docs/WriteRequestWrites.md
gradle.properties
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
Expand Down Expand Up @@ -102,7 +113,9 @@ src/main/java/dev/openfga/sdk/api/client/ClientReadAuthorizationModelsResponse.j
src/main/java/dev/openfga/sdk/api/client/ClientReadChangesResponse.java
src/main/java/dev/openfga/sdk/api/client/ClientReadRequest.java
src/main/java/dev/openfga/sdk/api/client/ClientReadResponse.java
src/main/java/dev/openfga/sdk/api/client/ClientRelationshipCondition.java
src/main/java/dev/openfga/sdk/api/client/ClientTupleKey.java
src/main/java/dev/openfga/sdk/api/client/ClientTupleKeyWithCondition.java
src/main/java/dev/openfga/sdk/api/client/ClientWriteAssertionsResponse.java
src/main/java/dev/openfga/sdk/api/client/ClientWriteAuthorizationModelResponse.java
src/main/java/dev/openfga/sdk/api/client/ClientWriteRequest.java
Expand Down Expand Up @@ -135,14 +148,18 @@ src/main/java/dev/openfga/sdk/api/model/Any.java
src/main/java/dev/openfga/sdk/api/model/Assertion.java
src/main/java/dev/openfga/sdk/api/model/AuthorizationModel.java
src/main/java/dev/openfga/sdk/api/model/CheckRequest.java
src/main/java/dev/openfga/sdk/api/model/CheckRequestTupleKey.java
src/main/java/dev/openfga/sdk/api/model/CheckResponse.java
src/main/java/dev/openfga/sdk/api/model/Computed.java
src/main/java/dev/openfga/sdk/api/model/Condition.java
src/main/java/dev/openfga/sdk/api/model/ConditionParamTypeRef.java
src/main/java/dev/openfga/sdk/api/model/ContextualTupleKeys.java
src/main/java/dev/openfga/sdk/api/model/CreateStoreRequest.java
src/main/java/dev/openfga/sdk/api/model/CreateStoreResponse.java
src/main/java/dev/openfga/sdk/api/model/Difference.java
src/main/java/dev/openfga/sdk/api/model/ErrorCode.java
src/main/java/dev/openfga/sdk/api/model/ExpandRequest.java
src/main/java/dev/openfga/sdk/api/model/ExpandRequestTupleKey.java
src/main/java/dev/openfga/sdk/api/model/ExpandResponse.java
src/main/java/dev/openfga/sdk/api/model/GetStoreResponse.java
src/main/java/dev/openfga/sdk/api/model/InternalErrorCode.java
Expand All @@ -155,25 +172,29 @@ src/main/java/dev/openfga/sdk/api/model/Metadata.java
src/main/java/dev/openfga/sdk/api/model/Node.java
src/main/java/dev/openfga/sdk/api/model/Nodes.java
src/main/java/dev/openfga/sdk/api/model/NotFoundErrorCode.java
src/main/java/dev/openfga/sdk/api/model/NullValue.java
src/main/java/dev/openfga/sdk/api/model/ObjectRelation.java
src/main/java/dev/openfga/sdk/api/model/PathUnknownErrorMessageResponse.java
src/main/java/dev/openfga/sdk/api/model/ReadAssertionsResponse.java
src/main/java/dev/openfga/sdk/api/model/ReadAuthorizationModelResponse.java
src/main/java/dev/openfga/sdk/api/model/ReadAuthorizationModelsResponse.java
src/main/java/dev/openfga/sdk/api/model/ReadChangesResponse.java
src/main/java/dev/openfga/sdk/api/model/ReadRequest.java
src/main/java/dev/openfga/sdk/api/model/ReadRequestTupleKey.java
src/main/java/dev/openfga/sdk/api/model/ReadResponse.java
src/main/java/dev/openfga/sdk/api/model/RelationMetadata.java
src/main/java/dev/openfga/sdk/api/model/RelationReference.java
src/main/java/dev/openfga/sdk/api/model/RelationshipCondition.java
src/main/java/dev/openfga/sdk/api/model/Status.java
src/main/java/dev/openfga/sdk/api/model/Store.java
src/main/java/dev/openfga/sdk/api/model/Tuple.java
src/main/java/dev/openfga/sdk/api/model/TupleChange.java
src/main/java/dev/openfga/sdk/api/model/TupleKey.java
src/main/java/dev/openfga/sdk/api/model/TupleKeys.java
src/main/java/dev/openfga/sdk/api/model/TupleKeyWithoutCondition.java
src/main/java/dev/openfga/sdk/api/model/TupleOperation.java
src/main/java/dev/openfga/sdk/api/model/TupleToUserset.java
src/main/java/dev/openfga/sdk/api/model/TypeDefinition.java
src/main/java/dev/openfga/sdk/api/model/TypeName.java
src/main/java/dev/openfga/sdk/api/model/Users.java
src/main/java/dev/openfga/sdk/api/model/Userset.java
src/main/java/dev/openfga/sdk/api/model/UsersetTree.java
Expand All @@ -185,6 +206,8 @@ src/main/java/dev/openfga/sdk/api/model/WriteAssertionsRequest.java
src/main/java/dev/openfga/sdk/api/model/WriteAuthorizationModelRequest.java
src/main/java/dev/openfga/sdk/api/model/WriteAuthorizationModelResponse.java
src/main/java/dev/openfga/sdk/api/model/WriteRequest.java
src/main/java/dev/openfga/sdk/api/model/WriteRequestDeletes.java
src/main/java/dev/openfga/sdk/api/model/WriteRequestWrites.java
src/main/java/dev/openfga/sdk/errors/ApiException.java
src/main/java/dev/openfga/sdk/errors/FgaApiAuthenticationError.java
src/main/java/dev/openfga/sdk/errors/FgaApiInternalError.java
Expand All @@ -209,14 +232,18 @@ src/test/java/dev/openfga/sdk/api/model/AnyTest.java
src/test/java/dev/openfga/sdk/api/model/AssertionTest.java
src/test/java/dev/openfga/sdk/api/model/AuthorizationModelTest.java
src/test/java/dev/openfga/sdk/api/model/CheckRequestTest.java
src/test/java/dev/openfga/sdk/api/model/CheckRequestTupleKeyTest.java
src/test/java/dev/openfga/sdk/api/model/CheckResponseTest.java
src/test/java/dev/openfga/sdk/api/model/ComputedTest.java
src/test/java/dev/openfga/sdk/api/model/ConditionParamTypeRefTest.java
src/test/java/dev/openfga/sdk/api/model/ConditionTest.java
src/test/java/dev/openfga/sdk/api/model/ContextualTupleKeysTest.java
src/test/java/dev/openfga/sdk/api/model/CreateStoreRequestTest.java
src/test/java/dev/openfga/sdk/api/model/CreateStoreResponseTest.java
src/test/java/dev/openfga/sdk/api/model/DifferenceTest.java
src/test/java/dev/openfga/sdk/api/model/ErrorCodeTest.java
src/test/java/dev/openfga/sdk/api/model/ExpandRequestTest.java
src/test/java/dev/openfga/sdk/api/model/ExpandRequestTupleKeyTest.java
src/test/java/dev/openfga/sdk/api/model/ExpandResponseTest.java
src/test/java/dev/openfga/sdk/api/model/GetStoreResponseTest.java
src/test/java/dev/openfga/sdk/api/model/InternalErrorCodeTest.java
Expand All @@ -229,25 +256,29 @@ src/test/java/dev/openfga/sdk/api/model/MetadataTest.java
src/test/java/dev/openfga/sdk/api/model/NodeTest.java
src/test/java/dev/openfga/sdk/api/model/NodesTest.java
src/test/java/dev/openfga/sdk/api/model/NotFoundErrorCodeTest.java
src/test/java/dev/openfga/sdk/api/model/NullValueTest.java
src/test/java/dev/openfga/sdk/api/model/ObjectRelationTest.java
src/test/java/dev/openfga/sdk/api/model/PathUnknownErrorMessageResponseTest.java
src/test/java/dev/openfga/sdk/api/model/ReadAssertionsResponseTest.java
src/test/java/dev/openfga/sdk/api/model/ReadAuthorizationModelResponseTest.java
src/test/java/dev/openfga/sdk/api/model/ReadAuthorizationModelsResponseTest.java
src/test/java/dev/openfga/sdk/api/model/ReadChangesResponseTest.java
src/test/java/dev/openfga/sdk/api/model/ReadRequestTest.java
src/test/java/dev/openfga/sdk/api/model/ReadRequestTupleKeyTest.java
src/test/java/dev/openfga/sdk/api/model/ReadResponseTest.java
src/test/java/dev/openfga/sdk/api/model/RelationMetadataTest.java
src/test/java/dev/openfga/sdk/api/model/RelationReferenceTest.java
src/test/java/dev/openfga/sdk/api/model/RelationshipConditionTest.java
src/test/java/dev/openfga/sdk/api/model/StatusTest.java
src/test/java/dev/openfga/sdk/api/model/StoreTest.java
src/test/java/dev/openfga/sdk/api/model/TupleChangeTest.java
src/test/java/dev/openfga/sdk/api/model/TupleKeyTest.java
src/test/java/dev/openfga/sdk/api/model/TupleKeysTest.java
src/test/java/dev/openfga/sdk/api/model/TupleKeyWithoutConditionTest.java
src/test/java/dev/openfga/sdk/api/model/TupleOperationTest.java
src/test/java/dev/openfga/sdk/api/model/TupleTest.java
src/test/java/dev/openfga/sdk/api/model/TupleToUsersetTest.java
src/test/java/dev/openfga/sdk/api/model/TypeDefinitionTest.java
src/test/java/dev/openfga/sdk/api/model/TypeNameTest.java
src/test/java/dev/openfga/sdk/api/model/UsersTest.java
src/test/java/dev/openfga/sdk/api/model/UsersetTest.java
src/test/java/dev/openfga/sdk/api/model/UsersetTreeDifferenceTest.java
Expand All @@ -258,5 +289,7 @@ src/test/java/dev/openfga/sdk/api/model/ValidationErrorMessageResponseTest.java
src/test/java/dev/openfga/sdk/api/model/WriteAssertionsRequestTest.java
src/test/java/dev/openfga/sdk/api/model/WriteAuthorizationModelRequestTest.java
src/test/java/dev/openfga/sdk/api/model/WriteAuthorizationModelResponseTest.java
src/test/java/dev/openfga/sdk/api/model/WriteRequestDeletesTest.java
src/test/java/dev/openfga/sdk/api/model/WriteRequestTest.java
src/test/java/dev/openfga/sdk/api/model/WriteRequestWritesTest.java
src/test/java/dev/openfga/sdk/util/StringUtilTest.java
50 changes: 35 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ import java.net.http.HttpClient;
public class Example {
public static void main(String[] args) throws Exception {
var config = new ClientConfiguration()
.apiUrl(System.getenv("OPENFGA_API_URL")) // If not specified, will default to "https://localhost:8080"
.storeId(System.getenv("OPENFGA_STORE_ID")) // Not required when calling createStore() or listStores()
.authorizationModelId(System.getenv("OPENFGA_AUTHORIZATION_MODEL_ID")); // Optional, can be overridden per request
.apiUrl(System.getenv("FGA_API_URL")) // If not specified, will default to "https://localhost:8080"
.storeId(System.getenv("FGA_STORE_ID")) // Not required when calling createStore() or listStores()
.authorizationModelId(System.getenv("FGA_AUTHORIZATION_MODEL_ID")); // Optional, can be overridden per request

var fgaClient = new OpenFgaClient(config);
var response = fgaClient.readAuthorizationModels().get();
Expand All @@ -152,11 +152,11 @@ import java.net.http.HttpClient;
public class Example {
public static void main(String[] args) throws Exception {
var config = new ClientConfiguration()
.apiUrl(System.getenv("OPENFGA_API_URL")) // If not specified, will default to "https://localhost:8080"
.storeId(System.getenv("OPENFGA_STORE_ID")) // Not required when calling createStore() or listStores()
.authorizationModelId(System.getenv("OPENFGA_AUTHORIZATION_MODEL_ID")) // Optional, can be overridden per request
.apiUrl(System.getenv("FGA_API_URL")) // If not specified, will default to "https://localhost:8080"
.storeId(System.getenv("FGA_STORE_ID")) // Not required when calling createStore() or listStores()
.authorizationModelId(System.getenv("FGA_AUTHORIZATION_MODEL_ID")) // Optional, can be overridden per request
.credentials(new Credentials(
new ApiToken(System.getenv("OPENFGA_API_TOKEN")) // will be passed as the "Authorization: Bearer ${ApiToken}" request header
new ApiToken(System.getenv("FGA_API_TOKEN")) // will be passed as the "Authorization: Bearer ${ApiToken}" request header
));

var fgaClient = new OpenFgaClient(config);
Expand All @@ -178,15 +178,15 @@ import java.net.http.HttpClient;
public class Example {
public static void main(String[] args) throws Exception {
var config = new ClientConfiguration()
.apiUrl(System.getenv("OPENFGA_API_URL")) // If not specified, will default to "https://localhost:8080"
.storeId(System.getenv("OPENFGA_STORE_ID")) // Not required when calling createStore() or listStores()
.authorizationModelId(System.getenv("OPENFGA_AUTHORIZATION_MODEL_ID")) // Optional, can be overridden per request
.apiUrl(System.getenv("FGA_API_URL")) // If not specified, will default to "https://localhost:8080"
.storeId(System.getenv("FGA_STORE_ID")) // Not required when calling createStore() or listStores()
.authorizationModelId(System.getenv("FGA_AUTHORIZATION_MODEL_ID")) // Optional, can be overridden per request
.credentials(new Credentials(
new ClientCredentials()
.apiTokenIssuer(System.getenv("OPENFGA_API_TOKEN_ISSUER"))
.apiAudience(System.getenv("OPENFGA_API_AUDIENCE"))
.clientId(System.getenv("OPENFGA_CLIENT_ID"))
.clientSecret(System.getenv("OPENFGA_CLIENT_SECRET"))
.apiTokenIssuer(System.getenv("FGA_API_TOKEN_ISSUER"))
.apiAudience(System.getenv("FGA_API_AUDIENCE"))
.clientId(System.getenv("FGA_CLIENT_ID"))
.clientSecret(System.getenv("FGA_CLIENT_SECRET"))
));

var fgaClient = new OpenFgaClient(config);
Expand Down Expand Up @@ -744,10 +744,16 @@ fgaClient.writeAssertions(assertions, options).get();

- [CheckRequest](https://github.com/openfga/java-sdk/blob/main/docs/CheckRequest.md)

- [CheckRequestTupleKey](https://github.com/openfga/java-sdk/blob/main/docs/CheckRequestTupleKey.md)

- [CheckResponse](https://github.com/openfga/java-sdk/blob/main/docs/CheckResponse.md)

- [Computed](https://github.com/openfga/java-sdk/blob/main/docs/Computed.md)

- [Condition](https://github.com/openfga/java-sdk/blob/main/docs/Condition.md)

- [ConditionParamTypeRef](https://github.com/openfga/java-sdk/blob/main/docs/ConditionParamTypeRef.md)

- [ContextualTupleKeys](https://github.com/openfga/java-sdk/blob/main/docs/ContextualTupleKeys.md)

- [CreateStoreRequest](https://github.com/openfga/java-sdk/blob/main/docs/CreateStoreRequest.md)
Expand All @@ -760,6 +766,8 @@ fgaClient.writeAssertions(assertions, options).get();

- [ExpandRequest](https://github.com/openfga/java-sdk/blob/main/docs/ExpandRequest.md)

- [ExpandRequestTupleKey](https://github.com/openfga/java-sdk/blob/main/docs/ExpandRequestTupleKey.md)

- [ExpandResponse](https://github.com/openfga/java-sdk/blob/main/docs/ExpandResponse.md)

- [GetStoreResponse](https://github.com/openfga/java-sdk/blob/main/docs/GetStoreResponse.md)
Expand All @@ -784,6 +792,8 @@ fgaClient.writeAssertions(assertions, options).get();

- [NotFoundErrorCode](https://github.com/openfga/java-sdk/blob/main/docs/NotFoundErrorCode.md)

- [NullValue](https://github.com/openfga/java-sdk/blob/main/docs/NullValue.md)

- [ObjectRelation](https://github.com/openfga/java-sdk/blob/main/docs/ObjectRelation.md)

- [PathUnknownErrorMessageResponse](https://github.com/openfga/java-sdk/blob/main/docs/PathUnknownErrorMessageResponse.md)
Expand All @@ -798,12 +808,16 @@ fgaClient.writeAssertions(assertions, options).get();

- [ReadRequest](https://github.com/openfga/java-sdk/blob/main/docs/ReadRequest.md)

- [ReadRequestTupleKey](https://github.com/openfga/java-sdk/blob/main/docs/ReadRequestTupleKey.md)

- [ReadResponse](https://github.com/openfga/java-sdk/blob/main/docs/ReadResponse.md)

- [RelationMetadata](https://github.com/openfga/java-sdk/blob/main/docs/RelationMetadata.md)

- [RelationReference](https://github.com/openfga/java-sdk/blob/main/docs/RelationReference.md)

- [RelationshipCondition](https://github.com/openfga/java-sdk/blob/main/docs/RelationshipCondition.md)

- [Status](https://github.com/openfga/java-sdk/blob/main/docs/Status.md)

- [Store](https://github.com/openfga/java-sdk/blob/main/docs/Store.md)
Expand All @@ -814,14 +828,16 @@ fgaClient.writeAssertions(assertions, options).get();

- [TupleKey](https://github.com/openfga/java-sdk/blob/main/docs/TupleKey.md)

- [TupleKeys](https://github.com/openfga/java-sdk/blob/main/docs/TupleKeys.md)
- [TupleKeyWithoutCondition](https://github.com/openfga/java-sdk/blob/main/docs/TupleKeyWithoutCondition.md)

- [TupleOperation](https://github.com/openfga/java-sdk/blob/main/docs/TupleOperation.md)

- [TupleToUserset](https://github.com/openfga/java-sdk/blob/main/docs/TupleToUserset.md)

- [TypeDefinition](https://github.com/openfga/java-sdk/blob/main/docs/TypeDefinition.md)

- [TypeName](https://github.com/openfga/java-sdk/blob/main/docs/TypeName.md)

- [Users](https://github.com/openfga/java-sdk/blob/main/docs/Users.md)

- [Userset](https://github.com/openfga/java-sdk/blob/main/docs/Userset.md)
Expand All @@ -844,6 +860,10 @@ fgaClient.writeAssertions(assertions, options).get();

- [WriteRequest](https://github.com/openfga/java-sdk/blob/main/docs/WriteRequest.md)

- [WriteRequestDeletes](https://github.com/openfga/java-sdk/blob/main/docs/WriteRequestDeletes.md)

- [WriteRequestWrites](https://github.com/openfga/java-sdk/blob/main/docs/WriteRequestWrites.md)



## Contributing
Expand Down
2 changes: 1 addition & 1 deletion docs/Assertion.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**tupleKey** | [**TupleKey**](TupleKey.md) | | |
|**tupleKey** | [**CheckRequestTupleKey**](CheckRequestTupleKey.md) | | |
|**expectation** | **Boolean** | | |


Expand Down
5 changes: 3 additions & 2 deletions docs/AuthorizationModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**id** | **String** | | [optional] |
|**id** | **String** | | |
|**schemaVersion** | **String** | | |
|**typeDefinitions** | [**List<TypeDefinition>**](TypeDefinition.md) | | [optional] |
|**typeDefinitions** | [**List<TypeDefinition>**](TypeDefinition.md) | | |
|**conditions** | [**Map<String, Condition>**](Condition.md) | | [optional] |



3 changes: 2 additions & 1 deletion docs/CheckRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**tupleKey** | [**TupleKey**](TupleKey.md) | | |
|**tupleKey** | [**CheckRequestTupleKey**](CheckRequestTupleKey.md) | | |
|**contextualTuples** | [**ContextualTupleKeys**](ContextualTupleKeys.md) | | [optional] |
|**authorizationModelId** | **String** | | [optional] |
|**trace** | **Boolean** | Defaults to false. Making it true has performance implications. | [optional] [readonly] |
|**context** | **Object** | Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation. | [optional] |



15 changes: 15 additions & 0 deletions docs/CheckRequestTupleKey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


# CheckRequestTupleKey


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**user** | **String** | | |
|**relation** | **String** | | |
|**_object** | **String** | | |



Loading

0 comments on commit 58c2993

Please sign in to comment.