This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,207 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
# Changelog | ||
|
||
|
||
## next | ||
|
||
* list server stores | ||
|
||
**migration** : | ||
|
||
If you already have configured servers with a previous version of this plugin you need to edit the `openfga-servers.xml` configuration file. | ||
|
||
This file is located in the `options` folder of your JetBrains IDE application data folder. | ||
|
||
* on windows it should be `%AppData%\JetBrains\<YourIDE>\options\openfga-servers.xml` | ||
* on linux it could be `~/.var/app/<your ide related subfolders>/options/openfga-servers.xml` | ||
|
||
Open the `openfga-servers.xml` file and rename all the `Server` elements to `ServerState`. | ||
|
||
## v0.2.2 | ||
|
||
* validate openfga cli configuration | ||
* format generated authorization model json file | ||
|
||
|
||
## v0.2.1 | ||
|
||
* only display OpenFGA actions group on OpenFGA files | ||
|
||
|
||
## v0.2.0 | ||
|
||
* add server oidc configuration support | ||
* add "test connection" in server dialog to check the configuration (checking a list stores api call doesn't fail) | ||
* improve error handling for authorization model json generation (also the action is disabled if required cli is not configured) | ||
|
||
|
||
## v0.1.0 | ||
|
||
* DSL syntax support (associated with `.fga` and `.openfga` file extensions) | ||
* Authorization model dsl file template | ||
* Authorization model dsl live templates | ||
* Generate json file from DSL (requires [OpenFGA CLI](https://github.com/openfga/cli) to be installed) | ||
* Configure servers in OpenFGA tool window |
29 changes: 0 additions & 29 deletions
29
src/main/java/com/github/le_yams/openfga4intellij/Notifier.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/github/le_yams/openfga4intellij/sdk/OpenFgaApiClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.github.le_yams.openfga4intellij.sdk; | ||
|
||
import com.github.le_yams.openfga4intellij.servers.model.Server; | ||
import com.github.le_yams.openfga4intellij.servers.util.ServersUtil; | ||
import dev.openfga.sdk.api.model.Store; | ||
import dev.openfga.sdk.errors.FgaInvalidParameterException; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface OpenFgaApiClient { | ||
|
||
CompletableFuture<List<Store>> listStores(); | ||
|
||
static OpenFgaApiClient ForServer(Server server) { | ||
try { | ||
var openFgaClient = ServersUtil.createClient(server); | ||
return new SdkClient(openFgaClient); | ||
} catch (FgaInvalidParameterException e) { | ||
throw new RuntimeException(e.getMessage(), e); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/com/github/le_yams/openfga4intellij/sdk/SdkClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.github.le_yams.openfga4intellij.sdk; | ||
|
||
import dev.openfga.sdk.api.client.OpenFgaClient; | ||
import dev.openfga.sdk.api.client.model.ClientListStoresResponse; | ||
import dev.openfga.sdk.api.configuration.ClientListStoresOptions; | ||
import dev.openfga.sdk.api.model.Store; | ||
import dev.openfga.sdk.errors.FgaInvalidParameterException; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.stream.Stream; | ||
|
||
class SdkClient implements OpenFgaApiClient { | ||
|
||
private static final int STORES_PAGE_SIZE = 50; | ||
|
||
private final OpenFgaClient fgaClient; | ||
|
||
public SdkClient(OpenFgaClient fgaClient) { | ||
this.fgaClient = fgaClient; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<List<Store>> listStores() { | ||
return listStores(new ClientListStoresOptions().pageSize(STORES_PAGE_SIZE)); | ||
} | ||
|
||
private CompletableFuture<List<Store>> listStores(ClientListStoresOptions options) { | ||
try { | ||
return fgaClient.listStores(options).thenCompose(this::listNextStores); | ||
} catch (FgaInvalidParameterException e) { | ||
throw new RuntimeException(e.getMessage(), e); | ||
} | ||
} | ||
|
||
private CompletableFuture<List<Store>> listNextStores(ClientListStoresResponse response) { | ||
var continuationToken = response.getContinuationToken(); | ||
if (continuationToken == null || continuationToken.isBlank()) { | ||
return CompletableFuture.completedFuture(response.getStores()); | ||
} | ||
|
||
try { | ||
return fgaClient | ||
.listStores(new ClientListStoresOptions().pageSize(STORES_PAGE_SIZE).continuationToken(continuationToken)) | ||
.thenCompose((ClientListStoresResponse nextResponse) -> | ||
listNextStores(nextResponse).thenApply(nextStores -> Stream.concat(response.getStores().stream(), nextStores.stream()).toList())); | ||
} catch (FgaInvalidParameterException e) { | ||
throw new RuntimeException(e.getMessage(), e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.