Search in sources :

Example 1 with AuthorizationCheck

use of org.camunda.bpm.engine.impl.db.AuthorizationCheck in project camunda-bpm-platform by camunda.

the class AuthorizationManager method configureQuery.

// authorization checks on queries ////////////////////////////////
public void configureQuery(ListQueryParameterObject query) {
    AuthorizationCheck authCheck = query.getAuthCheck();
    authCheck.getPermissionChecks().clear();
    if (isAuthCheckExecuted()) {
        Authentication currentAuthentication = getCurrentAuthentication();
        authCheck.setAuthUserId(currentAuthentication.getUserId());
        authCheck.setAuthGroupIds(currentAuthentication.getGroupIds());
        enableQueryAuthCheck(authCheck);
    } else {
        authCheck.setAuthorizationCheckEnabled(false);
        authCheck.setAuthUserId(null);
        authCheck.setAuthGroupIds(null);
    }
}
Also used : Authentication(org.camunda.bpm.engine.impl.identity.Authentication) AuthorizationCheck(org.camunda.bpm.engine.impl.db.AuthorizationCheck)

Example 2 with AuthorizationCheck

use of org.camunda.bpm.engine.impl.db.AuthorizationCheck in project camunda-bpm-platform by camunda.

the class AuthorizationManager method isAuthorized.

public boolean isAuthorized(String userId, List<String> groupIds, CompositePermissionCheck compositePermissionCheck) {
    List<String> filteredGroupIds = filterAuthenticatedGroupIds(groupIds);
    boolean isRevokeAuthorizationCheckEnabled = isRevokeAuthCheckEnabled(userId, groupIds);
    AuthorizationCheck authCheck = new AuthorizationCheck(userId, filteredGroupIds, compositePermissionCheck, isRevokeAuthorizationCheckEnabled);
    return getDbEntityManager().selectBoolean("isUserAuthorizedForResource", authCheck);
}
Also used : AuthorizationCheck(org.camunda.bpm.engine.impl.db.AuthorizationCheck)

Example 3 with AuthorizationCheck

use of org.camunda.bpm.engine.impl.db.AuthorizationCheck in project camunda-bpm-platform by camunda.

the class AuthorizationCheckRevokesCfgTest method shouldCheckDbForCfgValueWithNoRevokes_auto.

@Test
public void shouldCheckDbForCfgValueWithNoRevokes_auto() {
    final ListQueryParameterObject query = new ListQueryParameterObject();
    final AuthorizationCheck authCheck = query.getAuthCheck();
    final HashMap<String, Object> expectedQueryParams = new HashMap<String, Object>();
    expectedQueryParams.put("userId", AUTHENTICATED_USER_ID);
    expectedQueryParams.put("authGroupIds", AUTHENTICATED_GROUPS);
    // given
    when(mockedConfiguration.getAuthorizationCheckRevokes()).thenReturn(ProcessEngineConfiguration.AUTHORIZATION_CHECK_REVOKE_AUTO);
    when(mockedEntityManager.selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams))).thenReturn(false);
    // if
    authorizationManager.configureQuery(query);
    // then
    assertEquals(false, authCheck.isRevokeAuthorizationCheckEnabled());
    verify(mockedEntityManager, times(1)).selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams));
}
Also used : ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) HashMap(java.util.HashMap) ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) AuthorizationCheck(org.camunda.bpm.engine.impl.db.AuthorizationCheck) Test(org.junit.Test)

Example 4 with AuthorizationCheck

use of org.camunda.bpm.engine.impl.db.AuthorizationCheck in project camunda-bpm-platform by camunda.

the class AuthorizationCheckRevokesCfgTest method shouldCheckDbForCfgValue_auto.

@Test
public void shouldCheckDbForCfgValue_auto() {
    final ListQueryParameterObject query = new ListQueryParameterObject();
    final AuthorizationCheck authCheck = query.getAuthCheck();
    final HashMap<String, Object> expectedQueryParams = new HashMap<String, Object>();
    expectedQueryParams.put("userId", AUTHENTICATED_USER_ID);
    expectedQueryParams.put("authGroupIds", AUTHENTICATED_GROUPS);
    // given
    when(mockedConfiguration.getAuthorizationCheckRevokes()).thenReturn(ProcessEngineConfiguration.AUTHORIZATION_CHECK_REVOKE_AUTO);
    when(mockedEntityManager.selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams))).thenReturn(true);
    // if
    authorizationManager.configureQuery(query);
    // then
    assertEquals(true, authCheck.isRevokeAuthorizationCheckEnabled());
    verify(mockedEntityManager, times(1)).selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams));
}
Also used : ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) HashMap(java.util.HashMap) ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) AuthorizationCheck(org.camunda.bpm.engine.impl.db.AuthorizationCheck) Test(org.junit.Test)

Example 5 with AuthorizationCheck

use of org.camunda.bpm.engine.impl.db.AuthorizationCheck in project camunda-bpm-platform by camunda.

the class AuthorizationCheckRevokesCfgTest method shouldCheckDbForCfgCaseInsensitive.

@Test
public void shouldCheckDbForCfgCaseInsensitive() {
    final ListQueryParameterObject query = new ListQueryParameterObject();
    final AuthorizationCheck authCheck = query.getAuthCheck();
    final HashMap<String, Object> expectedQueryParams = new HashMap<String, Object>();
    expectedQueryParams.put("userId", AUTHENTICATED_USER_ID);
    expectedQueryParams.put("authGroupIds", AUTHENTICATED_GROUPS);
    // given
    when(mockedConfiguration.getAuthorizationCheckRevokes()).thenReturn("AuTo");
    when(mockedEntityManager.selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams))).thenReturn(true);
    // if
    authorizationManager.configureQuery(query);
    // then
    assertEquals(true, authCheck.isRevokeAuthorizationCheckEnabled());
    verify(mockedEntityManager, times(1)).selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams));
}
Also used : ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) HashMap(java.util.HashMap) ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) AuthorizationCheck(org.camunda.bpm.engine.impl.db.AuthorizationCheck) Test(org.junit.Test)

Aggregations

AuthorizationCheck (org.camunda.bpm.engine.impl.db.AuthorizationCheck)9 ListQueryParameterObject (org.camunda.bpm.engine.impl.db.ListQueryParameterObject)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)4 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)1