Skip to content

Commit fce4a0b

Browse files
Merge pull request #40 from anders-swanson/oke-workload-identity
OKE Workload Identity Authentication
2 parents 8e86783 + 555f724 commit fce4a0b

File tree

40 files changed

+71
-35
lines changed

40 files changed

+71
-35
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
**/*.rpm
66
**/*.jar
77
**/*.bin
8+
pom.xml.versionsBackup
89

910
### STS ###
1011
.apt_generated

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ For a deep dive into the project, refer to the Spring Cloud OCI documentation:
1515
| Version | Reference Docs | API Docs |
1616
|------------------------|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
1717
| Spring Cloud OCI 1.0.0 | [Reference Docs](https://oracle.github.io/spring-cloud-oci/1.0.0/reference/html/index.html) | [API Docs](https://oracle.github.io/spring-cloud-oci/1.0.0/javadocs/index.html) |
18-
| Spring Cloud OCI 1.0.1 | [Reference Docs](https://oracle.github.io/spring-cloud-oci/1.0.0/reference/html/index.html) | [API Docs](https://oracle.github.io/spring-cloud-oci/1.0.0/javadocs/index.html)
18+
| Spring Cloud OCI 1.0.1 | [Reference Docs](https://oracle.github.io/spring-cloud-oci/1.0.0/reference/html/index.html) | [API Docs](https://oracle.github.io/spring-cloud-oci/1.0.0/javadocs/index.html) |
19+
1920

2021
## Compatibility with Spring Project Versions
2122

@@ -25,6 +26,7 @@ This project has dependency and transitive dependencies on Spring Projects. The
2526
|------------------|--------------|--------------|--------------|
2627
| 1.0.0 | 2022.0.x | 3.1.x, 3.0.x | 3.24.0 |
2728
| 1.0.1 | 2023.0.x | 3.2.x | 3.41.1 |
29+
| 1.1.0 | 2023.0.x | 3.2.x | 3.41.1 |
2830

2931
## Try out samples
3032

docs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Licensed under the Universal Permissive License v 1.0 as shown at https://oss.or
1818
<name>spring-cloud-oci-docs</name>
1919
<groupId>com.oracle.cloud.spring</groupId>
2020
<artifactId>spring-cloud-oci-docs</artifactId>
21-
<version>1.0.1-SNAPSHOT</version>
21+
<version>1.1.0-SNAPSHOT</version>
2222
<packaging>pom</packaging>
2323
<licenses>
2424
<license>

docs/src/main/asciidoc/_configprops.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
|spring.cloud.oci.config.profile | `DEFAULT` | Name of the profile in OCI Auth config file
88
|spring.cloud.oci.config.file | NA | Location of the OCI Auth config file
9-
|spring.cloud.oci.config.type | FILE | Config/Auth type to be used. Allowed values are FILE, SIMPLE, INSTANCE_PRINCIPAL, RESOURCE_PRINCIPAL and SESSION_TOKEN
9+
|spring.cloud.oci.config.type | FILE | Config/Auth type to be used. Allowed values are FILE, SIMPLE, INSTANCE_PRINCIPAL, RESOURCE_PRINCIPAL, SESSION_TOKEN, and WORKLOAD_IDENTITY
1010
|spring.cloud.oci.config.userId | NA | OCID of the user used for creating the API key. This is needed only if spring.cloud.oci.config.type is `SIMPLE`
1111
|spring.cloud.oci.config.tenantId | NA | Tenancy OCID where the API key is created. This is needed only if spring.cloud.oci.config.type is `SIMPLE`
1212
|spring.cloud.oci.config.fingerprint | NA | Fingerprint for the public key that was added to the user mentioned in `spring.cloud.oci.config.userId`. This is needed only if spring.cloud.oci.config.type is `SIMPLE`

docs/src/main/asciidoc/core.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ Set the config.type to `SESSION_TOKEN` as shown here.
8282
spring.cloud.oci.config.type = SESSION_TOKEN
8383
----
8484

85+
==== Workload Identity Configuration
86+
87+
Set the config.type to `WORKLOAD_IDENTITY` as shown here.
88+
89+
----
90+
spring.cloud.oci.config.type = WORKLOAD_IDENTITY
91+
----
92+
93+
For further details, refer to https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contenggrantingworkloadaccesstoresources.htm[OKE Workload Identity Authentication]
94+
8595
For further details, refer to https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdk_authentication_methods.htm#ariaid-title12
8696

8797
=== Region Configuration

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Licensed under the Universal Permissive License v 1.0 as shown at https://oss.or
1616
</parent>
1717
<groupId>com.oracle.cloud.spring</groupId>
1818
<artifactId>spring-cloud-oci</artifactId>
19-
<version>1.0.1-SNAPSHOT</version>
19+
<version>1.1.0-SNAPSHOT</version>
2020
<packaging>pom</packaging>
2121

2222
<name>Spring Cloud OCI</name>

spring-cloud-oci-autoconfigure/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Licensed under the Universal Permissive License v 1.0 as shown at https://oss.or
1111
<parent>
1212
<artifactId>spring-cloud-oci</artifactId>
1313
<groupId>com.oracle.cloud.spring</groupId>
14-
<version>1.0.1-SNAPSHOT</version>
14+
<version>1.1.0-SNAPSHOT</version>
1515
</parent>
1616

1717
<artifactId>spring-cloud-oci-autoconfigure</artifactId>

spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/CredentialsProperties.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public enum ConfigType {
2222
FILE,
2323
INSTANCE_PRINCIPAL,
2424
RESOURCE_PRINCIPAL,
25+
WORKLOAD_IDENTITY,
2526
SIMPLE,
2627
SESSION_TOKEN
2728
}

spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/CredentialsProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.oracle.bmc.auth.SessionTokenAuthenticationDetailsProvider;
1515
import com.oracle.bmc.auth.SimpleAuthenticationDetailsProvider;
1616
import com.oracle.bmc.auth.SimplePrivateKeySupplier;
17+
import com.oracle.bmc.auth.okeworkloadidentity.OkeWorkloadIdentityAuthenticationDetailsProvider;
1718

1819
import java.io.IOException;
1920

@@ -41,6 +42,9 @@ private static BasicAuthenticationDetailsProvider createCredentialsProvider(Cred
4142
BasicAuthenticationDetailsProvider authenticationDetailsProvider;
4243

4344
switch (properties.getType()) {
45+
case WORKLOAD_IDENTITY:
46+
authenticationDetailsProvider = OkeWorkloadIdentityAuthenticationDetailsProvider.builder().build();
47+
break;
4448
case RESOURCE_PRINCIPAL:
4549
authenticationDetailsProvider = ResourcePrincipalAuthenticationDetailsProvider.builder().build();
4650
break;

spring-cloud-oci-autoconfigure/src/test/java/com/oracle/cloud/spring/autoconfigure/core/CredentialsProviderAutoConfigurationTests.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.oracle.bmc.Region;
99
import com.oracle.bmc.auth.*;
10+
import com.oracle.bmc.auth.okeworkloadidentity.OkeWorkloadIdentityAuthenticationDetailsProvider;
1011
import org.junit.jupiter.api.Test;
1112
import org.mockito.MockedConstruction;
1213
import org.mockito.MockedStatic;
@@ -71,6 +72,19 @@ void testConfigurationValueConfiguredAreAsExpected() {
7172
});
7273
}
7374

75+
@Test
76+
void testWorkloadIdentityProvider() throws Exception {
77+
CredentialsProperties properties = new CredentialsProperties();
78+
properties.setType(CredentialsProperties.ConfigType.WORKLOAD_IDENTITY);
79+
CredentialsProviderAutoConfiguration configuration = new CredentialsProviderAutoConfiguration(properties);
80+
try (MockedStatic mocked = mockStatic(OkeWorkloadIdentityAuthenticationDetailsProvider.class)) {
81+
OkeWorkloadIdentityAuthenticationDetailsProvider.OkeWorkloadIdentityAuthenticationDetailsProviderBuilder builder =
82+
mock(OkeWorkloadIdentityAuthenticationDetailsProvider.OkeWorkloadIdentityAuthenticationDetailsProviderBuilder.class);
83+
when(OkeWorkloadIdentityAuthenticationDetailsProvider.builder()).thenReturn(builder);
84+
BasicAuthenticationDetailsProvider provider = configuration.credentialsProvider().getAuthenticationDetailsProvider();
85+
}
86+
}
87+
7488
@Test
7589
void testResourcePrincipalProvider() throws Exception {
7690
CredentialsProperties properties = new CredentialsProperties();

0 commit comments

Comments
 (0)