Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Security and Compliance
entitlements-azure
Commits
e6ff4201
Commit
e6ff4201
authored
Sep 25, 2020
by
harshit aggarwal
Browse files
Initial commit
parent
1fd77123
Pipeline
#9879
failed with stages
in 3 minutes and 24 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
integration-tests/pom.xml
View file @
e6ff4201
...
...
@@ -107,6 +107,12 @@
<artifactId>
httpcore
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.8.6
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
...
...
pom.xml
View file @
e6ff4201
...
...
@@ -60,7 +60,7 @@
<springfox-version>
2.7.0
</springfox-version>
<reactor.netty.version>
0.9.0.RELEASE
</reactor.netty.version>
<reactor.core.version>
3.3.0.RELEASE
</reactor.core.version>
<osdu.azurecore.version>
0.0.
19
</osdu.azurecore.version>
<osdu.azurecore.version>
0.0.
28
</osdu.azurecore.version>
</properties>
<licenses>
...
...
src/main/java/org/opengroup/osdu/azure/entitlements/di/AzureBootstrapConfig.java
View file @
e6ff4201
...
...
@@ -16,14 +16,19 @@ package org.opengroup.osdu.azure.entitlements.di;
import
com.azure.security.keyvault.secrets.SecretClient
;
import
com.azure.security.keyvault.secrets.models.KeyVaultSecret
;
import
lombok.Getter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.PostConstruct
;
import
javax.inject.Named
;
@Configuration
@Getter
public
class
AzureBootstrapConfig
{
@Value
(
"${azure.keyvault.url}"
)
private
String
keyVaultURL
;
...
...
@@ -54,6 +59,16 @@ public class AzureBootstrapConfig {
@Value
(
"${azure.graph-api.version}"
)
private
String
graphApiVersion
;
private
String
appDevSpObjectId
;
@Autowired
private
SecretClient
secretClient
;
@PostConstruct
public
void
setAppDevSpObjectId
()
{
appDevSpObjectId
=
getKeyVaultSecret
(
secretClient
,
"app-dev-sp-object-id"
);
}
@Bean
@Named
(
"APP_DEV_SP_TENANT_ID"
)
public
String
appDevSpTenantId
(
SecretClient
kv
)
{
...
...
src/main/java/org/opengroup/osdu/azure/entitlements/repository/GroupInfoRepository.java
View file @
e6ff4201
...
...
@@ -71,7 +71,7 @@ public class GroupInfoRepository {
* @param tenantId
* @return The tenant info.
*/
p
rivate
Optional
<
TenantInfoDoc
>
findTenantInfo
(
String
tenantId
)
{
p
ublic
Optional
<
TenantInfoDoc
>
findTenantInfo
(
String
tenantId
)
{
return
cosmosStore
.
findItem
(
headers
.
getPartitionId
(),
cosmosDBName
,
tenantInfoContainer
,
tenantId
,
tenantId
,
TenantInfoDoc
.
class
);
}
}
\ No newline at end of file
src/main/java/org/opengroup/osdu/azure/entitlements/service/EntitlementsAzure.java
View file @
e6ff4201
...
...
@@ -19,9 +19,11 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.apache.http.HttpStatus
;
import
org.opengroup.osdu.azure.entitlements.di.AzureBootstrapConfig
;
import
org.opengroup.osdu.azure.entitlements.dto.CreateGroupRequest
;
import
org.opengroup.osdu.azure.entitlements.graph.IGraphService
;
import
org.opengroup.osdu.azure.entitlements.model.GroupInfoDoc
;
import
org.opengroup.osdu.azure.entitlements.model.TenantInfoDoc
;
import
org.opengroup.osdu.azure.entitlements.repository.GroupInfoRepository
;
import
org.opengroup.osdu.azure.entitlements.model.UserInfoDoc
;
import
org.opengroup.osdu.core.common.logging.JaxRsDpsLog
;
...
...
@@ -79,6 +81,9 @@ public class EntitlementsAzure
@Autowired
private
IGraphService
graphService
;
@Autowired
private
AzureBootstrapConfig
azureBootstrapConfig
;
@Data
@NoArgsConstructor
@AllArgsConstructor
...
...
@@ -241,6 +246,25 @@ public class EntitlementsAzure
String
[]
userTenantGroups
=
userInfoRepository
.
getTenantGroups
(
oid
,
headers
.
getPartitionId
());
// String[] userTenantGroups;
// if(oid.equals(azureBootstrapConfig.getAppDevSpObjectId())) {
// try {
// Optional<TenantInfoDoc> result = groupInfoRepository.findTenantInfo(headers.getPartitionId());
// if(!result.isPresent()) {
// throw new AppException(HttpStatus.SC_NOT_FOUND, "tenant not found", "the tenant does not exist");
// }
// userTenantGroups = result.get().getGroups();
// }
// catch (AppException exception) {
// throw new AppException(exception.getError().getCode(), exception.getError().getReason(), exception.getError().getMessage());
// }
// }
// else {
// userTenantGroups = userInfoRepository.getTenantGroups(oid, headers.getPartitionId());
// }
List
<
GroupInfo
>
groupInfoList
=
new
ArrayList
();
for
(
String
groupName
:
userTenantGroups
)
{
...
...
src/test/java/org/opengroup/osdu/azure/entitlements/di/AzureBootstrapConfigTest.java
View file @
e6ff4201
...
...
@@ -24,7 +24,7 @@ import static org.mockito.Mockito.doReturn;
public
class
AzureBootstrapConfigTest
{
private
AzureBootstrapConfig
bootstrapConfig
=
new
AzureBootstrapConfig
();
private
AzureBootstrapConfig
bootstrapConfig
=
new
AzureBootstrapConfig
(
Mockito
.
mock
(
SecretClient
.
class
)
);
private
SecretClient
kv
=
Mockito
.
mock
(
SecretClient
.
class
);
@Test
(
expected
=
IllegalStateException
.
class
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment