Skip to content
This repository was archived by the owner on Jul 7, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public AuthenticationManagerAllowAll() {
}

@Override User authenticate(String username, String secret) {
return new StaticUser(username, ImmutableList.of(), "unused", "unused");
return new StaticUser(username, ImmutableList.of(), "unused", "unused", false);
}

@Override User getUser(String username) {
return new StaticUser(username, ImmutableList.of(), "unused", "unused");
return new StaticUser(username, ImmutableList.of(), "unused", "unused", false);
}

@Override String sudoToken(String username) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,24 @@ public class StaticUser implements User {
@Nullable
private final String sudo;

private final boolean ignoreDiskQuota;

@JsonCreator
public StaticUser(@JsonProperty("name") String name,
@JsonProperty("groups") List<String> groups,
@JsonProperty("secret") String secret,
@JsonProperty("sudo") String sudo) {
@JsonProperty("sudo") String sudo,
@JsonProperty("ignoreDiskQuota") boolean ignoreDiskQuota) {
this.name = name;
this.groups = (groups == null) ? ImmutableList.of() : ImmutableList.copyOf(groups);
this.secret = secret;
this.sudo = sudo;
this.ignoreDiskQuota = ignoreDiskQuota;
}

@Override
public boolean ignoreDiskQuota() {
return ignoreDiskQuota;
}

@Nonnull @Override public String name() {
Expand Down
4 changes: 4 additions & 0 deletions hydra-main/src/main/java/com/addthis/hydra/job/auth/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public interface User {

@Nonnull List<String> groups();

default boolean ignoreDiskQuota() {
return false;
}

default @Nullable String primaryGroup() {
List<String> groups = groups();
if (groups.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

public class AuthenticationManagerNestedTest {

private static StaticUser user1 = new StaticUser("user1", ImmutableList.of("group2"), "unused", null);
private static StaticUser user2 = new StaticUser("user2", null, "password2", null);
private static StaticUser user3 = new StaticUser("user1", ImmutableList.of("group1"), "password1", null);
private static StaticUser user1 = new StaticUser("user1", ImmutableList.of("group2"), "unused", null, false);
private static StaticUser user2 = new StaticUser("user2", null, "password2", null, false);
private static StaticUser user3 = new StaticUser("user1", ImmutableList.of("group1"), "password1", null, false);

private static List<StaticUser> innerUsers = ImmutableList.of(user3);
private static List<StaticUser> outerUsers = ImmutableList.of(user1, user2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class AuthenticationManagerStaticTest {

@Test
public void authentication() {
StaticUser user1 = new StaticUser("user1", ImmutableList.of("group2"), null, null);
StaticUser user2 = new StaticUser("user2", null, "password2", null);
StaticUser user1 = new StaticUser("user1", ImmutableList.of("group2"), null, null, false);
StaticUser user2 = new StaticUser("user2", null, "password2", null, false);
List<StaticUser> users1 = ImmutableList.of(user1, user2);
AuthenticationManagerStatic auth = new AuthenticationManagerStatic(users1,
ImmutableList.of(),
Expand All @@ -45,9 +45,9 @@ public void authentication() {

@Test
public void isAdmin() {
StaticUser user1 = new StaticUser("user1", ImmutableList.of("group2"), null, null);
StaticUser user2 = new StaticUser("user2", null, "password2", null);
StaticUser user3 = new StaticUser("user3", ImmutableList.of("group2"), "password3", null);
StaticUser user1 = new StaticUser("user1", ImmutableList.of("group2"), null, null, false);
StaticUser user2 = new StaticUser("user2", null, "password2", null, false);
StaticUser user3 = new StaticUser("user3", ImmutableList.of("group2"), "password3", null, false);
List<StaticUser> users = ImmutableList.of(user1, user2, user3);
AuthenticationManagerStatic auth = new AuthenticationManagerStatic(users,
ImmutableList.of("group2"),
Expand Down