-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add odic client support and rename the package to add inventory (#3)
- Loading branch information
Showing
28 changed files
with
1,637 additions
and
42 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
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
45 changes: 45 additions & 0 deletions
45
src/main/java/org/project_kessel/inventory/client/Config.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,45 @@ | ||
package org.project_kessel.inventory.client; | ||
|
||
import io.smallrye.config.ConfigMapping; | ||
import io.smallrye.config.WithDefault; | ||
import io.smallrye.config.WithName; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Interface for injecting config into container managed beans. | ||
* It has the current limitation that only one underlying grpc connection can be configured. | ||
* Does nothing if this client is not being managed by a container. | ||
* Works directly for Quarkus. Might need an implementation class for future Spring Boot config. | ||
*/ | ||
@ConfigMapping(prefix = "inventory-api") | ||
public interface Config { | ||
enum AuthMode { | ||
DISABLED, | ||
OIDC_CLIENT_CREDENTIALS | ||
} | ||
|
||
@WithDefault("false") | ||
boolean isSecureClients(); | ||
String targetUrl(); | ||
|
||
@WithName("authn") | ||
Optional<AuthenticationConfig> authenticationConfig(); | ||
|
||
interface AuthenticationConfig { | ||
@WithDefault("disabled") | ||
AuthMode mode(); | ||
@WithName("client") | ||
Optional<OIDCClientCredentialsConfig> clientCredentialsConfig(); | ||
} | ||
|
||
interface OIDCClientCredentialsConfig { | ||
String issuer(); | ||
@WithName("id") | ||
String clientId(); | ||
@WithName("secret") | ||
String clientSecret(); | ||
Optional<String[]> scope(); | ||
Optional<String> oidcClientCredentialsMinterImplementation(); | ||
} | ||
} |
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
3 changes: 2 additions & 1 deletion
3
..._kessel/client/InventoryHealthClient.java → ...ventory/client/InventoryHealthClient.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
3 changes: 2 additions & 1 deletion
3
...ject_kessel/client/K8sClustersClient.java → ...l/inventory/client/K8sClustersClient.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
3 changes: 2 additions & 1 deletion
3
...lient/NotificationsIntegrationClient.java → ...lient/NotificationsIntegrationClient.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
2 changes: 1 addition & 1 deletion
2
...project_kessel/client/PoliciesClient.java → ...ssel/inventory/client/PoliciesClient.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
3 changes: 2 additions & 1 deletion
3
...ssel/client/PolicyRelationshipClient.java → ...tory/client/PolicyRelationshipClient.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
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
39 changes: 39 additions & 0 deletions
39
src/main/java/org/project_kessel/inventory/client/authn/CallCredentialsFactory.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,39 @@ | ||
package org.project_kessel.inventory.client.authn; | ||
|
||
import io.grpc.CallCredentials; | ||
import org.project_kessel.inventory.client.Config; | ||
import org.project_kessel.inventory.client.authn.oidc.client.OIDCClientCredentialsCallCredentials; | ||
|
||
public class CallCredentialsFactory { | ||
|
||
private CallCredentialsFactory() { | ||
|
||
} | ||
|
||
public static CallCredentials create(Config.AuthenticationConfig authnConfig) throws CallCredentialsCreationException { | ||
if (authnConfig == null) { | ||
throw new CallCredentialsCreationException("AuthenticationConfig is required to create CallCredentials and must not be null."); | ||
} | ||
|
||
try { | ||
switch (authnConfig.mode()) { | ||
case DISABLED: return null; | ||
case OIDC_CLIENT_CREDENTIALS: return new OIDCClientCredentialsCallCredentials(authnConfig); | ||
} | ||
} catch (OIDCClientCredentialsCallCredentials.OIDCClientCredentialsCallCredentialsException e) { | ||
throw new CallCredentialsCreationException("Failed to create OIDCClientCredentialsCallCredentials.", e); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static class CallCredentialsCreationException extends Exception { | ||
public CallCredentialsCreationException(String message) { | ||
super(message); | ||
} | ||
|
||
public CallCredentialsCreationException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} | ||
} |
Oops, something went wrong.