Skip to content

Commit 94d5096

Browse files
committed
Issue #6 - support view resource
1 parent 2e12419 commit 94d5096

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<dependency>
4040
<groupId>mesosphere.marathon</groupId>
4141
<artifactId>plugin-interface_2.11</artifactId>
42-
<version>1.3.1</version>
42+
<version>1.3.2</version>
4343
<scope>provided</scope>
4444
</dependency>
4545
<dependency>

src/main/java/io/containx/marathon/plugin/auth/LDAPAuthorizor.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,27 @@ public <Resource> boolean isAuthorized(Identity identity, AuthorizedAction<Resou
2424
if (identity instanceof UserIdentity) {
2525
UserIdentity user = (UserIdentity) identity;
2626
Action action = Action.byAction(authorizedAction);
27+
2728
if (resource instanceof Group) {
2829
return isAuthorized(user, action, ((Group) resource).id());
2930
}
3031
if (resource instanceof RunSpec) {
3132
return isAuthorized(user, action, ((RunSpec) resource).id());
3233
}
34+
35+
// We don't get the PathID from View Resource but prior calls ensure the RunSpec is authorized
36+
// in general
37+
if (action == Action.VIEW_RESOURCE) {
38+
return true;
39+
}
3340
return resource instanceof PathId && isAuthorized(user, action, (PathId) resource);
3441
}
3542
return false;
3643
}
3744

3845
private boolean isAuthorized(UserIdentity identity, Action action, PathId path) {
3946
boolean authorized = identity.isAuthorized(action, path.toString());
40-
LOGGER.debug("IsAuthorized: Action :: {}, Path = {}, authorized :: {}" + action, path.toString(), authorized);
47+
LOGGER.debug("IsAuthorized (private): Action :: {}, Path = {}, authorized = {}", action, path.toString(), authorized);
4148
return authorized;
4249
}
4350

src/main/java/io/containx/marathon/plugin/auth/type/Action.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.containx.marathon.plugin.auth.type;
22

3-
import mesosphere.marathon.plugin.auth.AuthorizedAction;
3+
import com.google.common.base.MoreObjects;
44
import mesosphere.marathon.plugin.auth.*;
55

66
/**
@@ -47,4 +47,13 @@ public EntityType getEntityType() {
4747
public PermissionType getPermType() {
4848
return permType;
4949
}
50+
51+
@Override
52+
public String toString() {
53+
return MoreObjects.toStringHelper(this)
54+
.add("action", action)
55+
.add("entityType", entityType)
56+
.add("permType", permType)
57+
.toString();
58+
}
5059
}

src/main/java/io/containx/marathon/plugin/auth/util/HTTPHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static AuthKey authKeyFromHeaders(HttpRequest request) throws Exception {
2020
String encoded = header.get().replaceFirst("Basic ", "");
2121
String decoded = new String(Base64.getDecoder().decode(encoded), "UTF-8");
2222
String[] userPass = decoded.split(":", 2);
23-
LOGGER.error("Returning username {} from HTTP Request headers", userPass[0]);
23+
2424
return AuthKey.with(userPass[0], userPass[1]);
2525
}
2626
return null;

0 commit comments

Comments
 (0)