Skip to content
GitLab
Menu
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
Data Flow
Data Ingestion
Ingestion Workflow
Commits
4a8facd4
Commit
4a8facd4
authored
Sep 22, 2021
by
Aalekh Jain
Browse files
Code formatting
Using isDomainAdminServiceAccount instead of isRootUser
parent
96695317
Changes
9
Hide whitespace changes
Inline
Side-by-side
provider/workflow-aws/src/main/java/org/opengroup/osdu/workflow/aws/service/
Root
AuthorizationServiceImpl.java
→
provider/workflow-aws/src/main/java/org/opengroup/osdu/workflow/aws/service/
Admin
AuthorizationServiceImpl.java
View file @
4a8facd4
package
org.opengroup.osdu.workflow.aws.service
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Root
AuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Admin
AuthorizationService
;
import
org.springframework.stereotype.Component
;
@Component
public
class
Root
AuthorizationServiceImpl
implements
I
Root
AuthorizationService
{
public
class
Admin
AuthorizationServiceImpl
implements
I
Admin
AuthorizationService
{
@Override
public
boolean
is
RootUser
()
{
public
boolean
is
DomainAdminServiceAccount
()
{
return
false
;
}
}
provider/workflow-azure/src/main/java/org/opengroup/osdu/workflow/provider/azure/service/
Root
AuthorizationServiceImpl.java
→
provider/workflow-azure/src/main/java/org/opengroup/osdu/workflow/provider/azure/service/
Admin
AuthorizationServiceImpl.java
View file @
4a8facd4
...
...
@@ -2,7 +2,7 @@ package org.opengroup.osdu.workflow.provider.azure.service;
import
com.microsoft.azure.spring.autoconfigure.aad.UserPrincipal
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Root
AuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Admin
AuthorizationService
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Component
;
...
...
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
import
java.util.Map
;
@Component
public
class
Root
AuthorizationServiceImpl
implements
I
Root
AuthorizationService
{
public
class
Admin
AuthorizationServiceImpl
implements
I
Admin
AuthorizationService
{
enum
UserType
{
REGULAR_USER
,
GUEST_USER
,
...
...
@@ -18,7 +18,7 @@ public class RootAuthorizationServiceImpl implements IRootAuthorizationService {
}
@Override
public
boolean
is
RootUser
()
{
public
boolean
is
DomainAdminServiceAccount
()
{
final
Object
principal
=
getUserPrincipal
();
if
(!(
principal
instanceof
UserPrincipal
))
{
...
...
provider/workflow-gcp/src/main/java/org/opengroup/osdu/workflow/provider/gcp/service/
Root
AuthorizationServiceImpl.java
→
provider/workflow-gcp/src/main/java/org/opengroup/osdu/workflow/provider/gcp/service/
Admin
AuthorizationServiceImpl.java
View file @
4a8facd4
package
org.opengroup.osdu.workflow.provider.gcp.service
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Root
AuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Admin
AuthorizationService
;
import
org.springframework.stereotype.Service
;
@Service
public
class
Root
AuthorizationServiceImpl
implements
I
Root
AuthorizationService
{
public
class
Admin
AuthorizationServiceImpl
implements
I
Admin
AuthorizationService
{
@Override
public
boolean
is
RootUser
()
{
public
boolean
is
DomainAdminServiceAccount
()
{
return
false
;
}
}
provider/workflow-ibm/src/main/java/org/opengroup/osdu/workflow/provider/ibm/service/
Root
AuthorizationServiceImpl.java
→
provider/workflow-ibm/src/main/java/org/opengroup/osdu/workflow/provider/ibm/service/
Admin
AuthorizationServiceImpl.java
View file @
4a8facd4
package
org.opengroup.osdu.workflow.provider.ibm.service
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Root
AuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Admin
AuthorizationService
;
import
org.springframework.stereotype.Component
;
@Component
public
class
Root
AuthorizationServiceImpl
implements
I
Root
AuthorizationService
{
public
class
Admin
AuthorizationServiceImpl
implements
I
Admin
AuthorizationService
{
@Override
public
boolean
is
RootUser
()
{
public
boolean
is
DomainAdminServiceAccount
()
{
return
false
;
}
}
workflow-core/src/main/java/org/opengroup/osdu/workflow/provider/interfaces/I
Root
AuthorizationService.java
→
workflow-core/src/main/java/org/opengroup/osdu/workflow/provider/interfaces/I
Admin
AuthorizationService.java
View file @
4a8facd4
package
org.opengroup.osdu.workflow.provider.interfaces
;
public
interface
I
Root
AuthorizationService
{
boolean
is
RootUser
();
public
interface
I
Admin
AuthorizationService
{
boolean
is
DomainAdminServiceAccount
();
}
workflow-core/src/main/java/org/opengroup/osdu/workflow/security/AuthorizationFilter.java
View file @
4a8facd4
...
...
@@ -24,7 +24,7 @@ import org.opengroup.osdu.core.common.exception.UnauthorizedException;
import
org.opengroup.osdu.core.common.model.entitlements.AuthorizationResponse
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.opengroup.osdu.core.common.provider.interfaces.IAuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Root
AuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Admin
AuthorizationService
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.annotation.RequestScope
;
...
...
@@ -38,7 +38,7 @@ public class AuthorizationFilter {
final
DpsHeaders
headers
;
final
I
Root
AuthorizationService
root
AuthorizationService
;
final
I
Admin
AuthorizationService
admin
AuthorizationService
;
/**
* Check the access permission for provided Authorization header and the required roles.
...
...
@@ -63,7 +63,7 @@ public class AuthorizationFilter {
throw
new
BadRequestException
(
"data-partition-id header should not be passed"
);
}
headers
.
put
(
DpsHeaders
.
USER_EMAIL
,
"RootUser"
);
return
root
AuthorizationService
.
is
RootUser
();
return
admin
AuthorizationService
.
is
DomainAdminServiceAccount
();
}
private
void
validateMandatoryHeaders
()
{
...
...
workflow-core/src/test/java/org/opengroup/osdu/workflow/api/WorkflowManagerMvcTest.java
View file @
4a8facd4
...
...
@@ -14,7 +14,7 @@ import org.opengroup.osdu.workflow.exception.handler.ConflictApiError;
import
org.opengroup.osdu.workflow.model.CreateWorkflowRequest
;
import
org.opengroup.osdu.workflow.model.WorkflowMetadata
;
import
org.opengroup.osdu.workflow.model.WorkflowRole
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Root
AuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Admin
AuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.IWorkflowManagerService
;
import
org.opengroup.osdu.workflow.security.AuthorizationFilter
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -105,7 +105,7 @@ class WorkflowManagerMvcTest {
private
IAuthorizationService
authorizationService
;
@MockBean
private
I
Root
AuthorizationService
root
AuthorizationService
;
private
I
Admin
AuthorizationService
admin
AuthorizationService
;
@MockBean
private
JaxRsDpsLog
log
;
...
...
workflow-core/src/test/java/org/opengroup/osdu/workflow/api/WorkflowRunMvcTest.java
View file @
4a8facd4
...
...
@@ -12,7 +12,7 @@ import org.opengroup.osdu.workflow.exception.handler.RestExceptionHandler;
import
org.opengroup.osdu.workflow.model.UpdateWorkflowRunRequest
;
import
org.opengroup.osdu.workflow.model.WorkflowRole
;
import
org.opengroup.osdu.workflow.model.WorkflowRunResponse
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Root
AuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Admin
AuthorizationService
;
import
org.opengroup.osdu.workflow.security.AuthorizationFilter
;
import
org.opengroup.osdu.workflow.model.TriggerWorkflowRequest
;
import
org.opengroup.osdu.workflow.provider.interfaces.IWorkflowRunService
;
...
...
@@ -107,7 +107,7 @@ class WorkflowRunMvcTest {
@MockBean
private
IAuthorizationService
authorizationService
;
@MockBean
private
I
Root
AuthorizationService
root
AuthorizationService
;
private
I
Admin
AuthorizationService
admin
AuthorizationService
;
@MockBean
private
RestExceptionHandler
restExceptionHandler
;
@MockBean
...
...
workflow-core/src/test/java/org/opengroup/osdu/workflow/api/WorkflowSystemManagerMvcTest.java
View file @
4a8facd4
...
...
@@ -13,7 +13,7 @@ import org.opengroup.osdu.workflow.exception.WorkflowNotFoundException;
import
org.opengroup.osdu.workflow.exception.handler.ConflictApiError
;
import
org.opengroup.osdu.workflow.model.CreateWorkflowRequest
;
import
org.opengroup.osdu.workflow.model.WorkflowMetadata
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Root
AuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.I
Admin
AuthorizationService
;
import
org.opengroup.osdu.workflow.provider.interfaces.IWorkflowManagerService
;
import
org.opengroup.osdu.workflow.security.AuthorizationFilter
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -81,7 +81,7 @@ class WorkflowSystemManagerMvcTest {
private
IAuthorizationService
authorizationService
;
@MockBean
private
I
Root
AuthorizationService
root
AuthorizationService
;
private
I
Admin
AuthorizationService
admin
AuthorizationService
;
@MockBean
private
JaxRsDpsLog
log
;
...
...
@@ -98,7 +98,7 @@ class WorkflowSystemManagerMvcTest {
.
readValue
(
WORKFLOW_REQUEST
,
CreateWorkflowRequest
.
class
);
final
WorkflowMetadata
metadata
=
mapper
.
readValue
(
WORKFLOW_RESPONSE
,
WorkflowMetadata
.
class
);
when
(
workflowManagerService
.
createSystemWorkflow
(
eq
(
request
))).
thenReturn
(
metadata
);
when
(
root
AuthorizationService
.
is
RootUser
())
when
(
admin
AuthorizationService
.
is
DomainAdminServiceAccount
())
.
thenReturn
(
true
);
when
(
dpsHeaders
.
getAuthorization
()).
thenReturn
(
TEST_AUTH
);
when
(
dpsHeaders
.
getPartitionId
()).
thenReturn
(
""
);
...
...
@@ -112,7 +112,7 @@ class WorkflowSystemManagerMvcTest {
.
andExpect
(
status
().
isOk
())
.
andReturn
();
verify
(
workflowManagerService
).
createSystemWorkflow
(
eq
(
request
));
verify
(
root
AuthorizationService
).
is
RootUser
();
verify
(
admin
AuthorizationService
).
is
DomainAdminServiceAccount
();
verify
(
dpsHeaders
).
getAuthorization
();
verify
(
dpsHeaders
).
getPartitionId
();
final
WorkflowMetadata
responseMetadata
=
...
...
@@ -125,7 +125,7 @@ class WorkflowSystemManagerMvcTest {
final
CreateWorkflowRequest
request
=
mapper
.
readValue
(
WORKFLOW_REQUEST
,
CreateWorkflowRequest
.
class
);
when
(
workflowManagerService
.
createSystemWorkflow
(
eq
(
request
)))
.
thenThrow
(
new
ResourceConflictException
(
EXISTING_WORKFLOW_ID
,
"conflict"
));
when
(
root
AuthorizationService
.
is
RootUser
())
when
(
admin
AuthorizationService
.
is
DomainAdminServiceAccount
())
.
thenReturn
(
true
);
when
(
dpsHeaders
.
getAuthorization
()).
thenReturn
(
TEST_AUTH
);
when
(
dpsHeaders
.
getPartitionId
()).
thenReturn
(
""
);
...
...
@@ -139,7 +139,7 @@ class WorkflowSystemManagerMvcTest {
.
andExpect
(
status
().
isConflict
())
.
andReturn
();
verify
(
workflowManagerService
).
createSystemWorkflow
(
eq
(
request
));
when
(
root
AuthorizationService
.
is
RootUser
())
when
(
admin
AuthorizationService
.
is
DomainAdminServiceAccount
())
.
thenReturn
(
true
);
verify
(
dpsHeaders
).
getAuthorization
();
verify
(
dpsHeaders
).
getPartitionId
();
...
...
@@ -151,7 +151,7 @@ class WorkflowSystemManagerMvcTest {
@Test
void
testDeleteSystemApiWithSuccess
()
throws
Exception
{
doNothing
().
when
(
workflowManagerService
).
deleteSystemWorkflow
(
eq
(
WORKFLOW_NAME
));
when
(
root
AuthorizationService
.
is
RootUser
())
when
(
admin
AuthorizationService
.
is
DomainAdminServiceAccount
())
.
thenReturn
(
true
);
when
(
dpsHeaders
.
getAuthorization
()).
thenReturn
(
TEST_AUTH
);
when
(
dpsHeaders
.
getCorrelationId
()).
thenReturn
(
CORRELATION_ID
);
...
...
@@ -163,7 +163,7 @@ class WorkflowSystemManagerMvcTest {
.
andExpect
(
status
().
is
(
204
))
.
andReturn
();
verify
(
workflowManagerService
).
deleteSystemWorkflow
(
eq
(
WORKFLOW_NAME
));
verify
(
root
AuthorizationService
).
is
RootUser
();
verify
(
admin
AuthorizationService
).
is
DomainAdminServiceAccount
();
verify
(
dpsHeaders
).
getAuthorization
();
}
...
...
@@ -171,7 +171,7 @@ class WorkflowSystemManagerMvcTest {
void
testDeleteSystemApiWithError
()
throws
Exception
{
doThrow
(
new
WorkflowNotFoundException
(
"not found"
)).
when
(
workflowManagerService
)
.
deleteSystemWorkflow
(
eq
(
WORKFLOW_NAME
));
when
(
root
AuthorizationService
.
is
RootUser
())
when
(
admin
AuthorizationService
.
is
DomainAdminServiceAccount
())
.
thenReturn
(
true
);
when
(
dpsHeaders
.
getAuthorization
()).
thenReturn
(
TEST_AUTH
);
when
(
dpsHeaders
.
getPartitionId
()).
thenReturn
(
""
);
...
...
@@ -184,7 +184,7 @@ class WorkflowSystemManagerMvcTest {
.
andExpect
(
status
().
isNotFound
())
.
andReturn
();
verify
(
workflowManagerService
).
deleteSystemWorkflow
(
eq
(
WORKFLOW_NAME
));
verify
(
root
AuthorizationService
).
is
RootUser
();
verify
(
admin
AuthorizationService
).
is
DomainAdminServiceAccount
();
verify
(
dpsHeaders
).
getAuthorization
();
verify
(
dpsHeaders
).
getPartitionId
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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