Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source column #1195

Closed
wants to merge 16 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
branches:
only:
- master
- elide-5.x
- "/^[0-9]+\\.[0-9]+(\\.[0-9]+|-(alpha|beta)-[0-9]+)/"

install: true
Expand Down
2 changes: 1 addition & 1 deletion checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
<suppressions>
<!-- Suppress generated sources -->
<suppress files="[/\\]src[/\\]test[/\\]" checks="(JavadocType|LineLength|MethodLength)"/>
<suppress files="[/\\]src[/\\]test[/\\]" checks="(JavadocType|LineLength|MethodLength|MethodCount)"/>
<suppress files="[/\\]src[/\\]main[/\\]webapp[/\\]WEB-INF[/\\]api-docs[/\\]" checks=".*"/>
<suppress files="[/\\]target[/\\]" checks=".*"/>
<suppress files="\.csv" checks=".*"/>
Expand Down
3 changes: 1 addition & 2 deletions elide-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.yahoo.elide</groupId>
<artifactId>elide-parent-pom</artifactId>
<version>4.5.14-SNAPSHOT</version>
<version>5.0.0-pr7-SNAPSHOT</version>
</parent>

<licenses>
Expand Down Expand Up @@ -53,5 +53,4 @@
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

Expand All @@ -20,6 +19,5 @@
*/
@Target({METHOD, FIELD, TYPE, PACKAGE})
@Retention(RUNTIME)
@Inherited
public @interface Exclude {
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

Expand All @@ -18,7 +17,6 @@
*/
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
@Inherited
public @interface Include {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2020, Yahoo Inc.
* Licensed under the Apache License, Version 2.0
* See LICENSE file in project root for terms.
*/
package com.yahoo.elide.annotation;

import static java.lang.annotation.ElementType.PACKAGE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* Marks that the given entity cannot be added to another collection after creation of the entity.
*/
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
@Inherited
public @interface NonTransferable {

/**
* If NonTransferable is used at the package level, it can be disabled for individual entities by setting
* this flag to false.
* @return true if enabled.
*/
boolean enabled() default true;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,9 @@
* See LICENSE file in project root for terms.
*/
package com.yahoo.elide.security.checks;

import com.yahoo.elide.security.ChangeSpec;
import com.yahoo.elide.security.RequestScope;
import com.yahoo.elide.security.User;

import java.util.Optional;

/**
* Custom security access that verifies whether a user belongs to a role.
* Permissions are assigned as a set of checks that grant access to the permission.
* @param <T> Type of record for Check
*/
public interface Check<T> {

/**
* Determines whether the user can access the resource.
*
* @param object Fully modified object
* @param requestScope Request scope object
* @param changeSpec Summary of modifications
* @return true if security check passed
*/
boolean ok(T object, RequestScope requestScope, Optional<ChangeSpec> changeSpec);

/**
* Method reserved for user checks.
*
* @param user User to check
* @return True if user check passes, false otherwise
*/
boolean ok(User user);

default String checkIdentifier() {
return this.getClass().getName();
}
public interface Check {
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
*/
package com.yahoo.elide.security.checks;

import com.yahoo.elide.security.User;
import com.yahoo.elide.security.ChangeSpec;
import com.yahoo.elide.security.RequestScope;

import java.util.Optional;

/**
* Operation check interface.
Expand All @@ -18,10 +21,14 @@
*
* @param <T> Type parameter
*/
public abstract class OperationCheck<T> extends InlineCheck<T> {
/* NOTE: Operation checks and user checks are intended to be _distinct_ */
@Override
public final boolean ok(User user) {
throw new UnsupportedOperationException();
}
public abstract class OperationCheck<T> implements Check {
/**
* Determines whether the user can access the resource.
*
* @param object Fully modified object
* @param requestScope Request scope object
* @param changeSpec Summary of modifications
* @return true if security check passed
*/
public abstract boolean ok(T object, RequestScope requestScope, Optional<ChangeSpec> changeSpec);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
*/
package com.yahoo.elide.security.checks;

import com.yahoo.elide.security.ChangeSpec;
import com.yahoo.elide.security.RequestScope;

import java.util.Optional;
import com.yahoo.elide.security.User;

/**
* Custom security access that verifies whether a user belongs to a role.
* Permissions are assigned as a set of checks that grant access to the permission.
*/
public abstract class UserCheck extends InlineCheck<Object> {
/* NOTE: Operation checks and user checks are intended to be _distinct_ */
@Override
public final boolean ok(Object object, RequestScope requestScope, Optional<ChangeSpec> changeSpec) {
return ok(requestScope.getUser());
}
public abstract class UserCheck implements Check {
/**
* Method reserved for user checks.
*
* @param user User to check
* @return True if user check passes, false otherwise
*/
public abstract boolean ok(User user);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import com.yahoo.elide.security.ChangeSpec;
import com.yahoo.elide.security.RequestScope;
import com.yahoo.elide.security.checks.CommitCheck;
import com.yahoo.elide.security.checks.OperationCheck;

import java.util.Collection;
import java.util.Optional;
Expand All @@ -27,7 +27,7 @@ private Collections() {
*
* @param <T> type collection to be validated
*/
public static class AppendOnly<T> extends CommitCheck<T> {
public static class AppendOnly<T> extends OperationCheck<T> {

@Override
public boolean ok(T record, RequestScope requestScope, Optional<ChangeSpec> changeSpec) {
Expand All @@ -47,7 +47,7 @@ public boolean ok(T record, RequestScope requestScope, Optional<ChangeSpec> chan
*
* @param <T> type parameter
*/
public static class RemoveOnly<T> extends CommitCheck<T> {
public static class RemoveOnly<T> extends OperationCheck<T> {

@Override
public boolean ok(T record, RequestScope requestScope, Optional<ChangeSpec> changeSpec) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.yahoo.elide.security.ChangeSpec;
import com.yahoo.elide.security.PersistentResource;
import com.yahoo.elide.security.RequestScope;
import com.yahoo.elide.security.checks.CommitCheck;
import com.yahoo.elide.security.checks.OperationCheck;

import java.util.Optional;
Expand Down Expand Up @@ -42,7 +41,7 @@ public boolean ok(T record, RequestScope requestScope, Optional<ChangeSpec> chan
* but at the same time allows the removal of the child from the relationship with the existing parent
* @param <T> the type of object that this check guards
*/
public static class FieldSetToNull<T> extends CommitCheck<T> {
public static class FieldSetToNull<T> extends OperationCheck<T> {
@Override
public boolean ok(T record, RequestScope requestScope, Optional<ChangeSpec> changeSpec) {
return changeSpec.map((c) -> { return c.getModified() == null; })
Expand Down
6 changes: 3 additions & 3 deletions elide-contrib/elide-swagger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<artifactId>elide-contrib-parent-pom</artifactId>
<groupId>com.yahoo.elide</groupId>
<version>4.5.14-SNAPSHOT</version>
<version>5.0.0-pr7-SNAPSHOT</version>
</parent>

<licenses>
Expand Down Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>com.yahoo.elide</groupId>
<artifactId>elide-core</artifactId>
<version>4.5.14-SNAPSHOT</version>
<version>5.0.0-pr7-SNAPSHOT</version>
</dependency>

<dependency>
Expand All @@ -54,7 +54,7 @@
<dependency>
<groupId>com.yahoo.elide</groupId>
<artifactId>elide-integration-tests</artifactId>
<version>4.5.14-SNAPSHOT</version>
<version>5.0.0-pr7-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,9 @@ public Swagger build() {
converters.addConverter(new JsonApiModelResolver(dictionary));

if (allClasses.isEmpty()) {
allClasses = dictionary.getBindings();
allClasses = dictionary.getBoundClasses();
} else {
allClasses = Sets.intersection(dictionary.getBindings(), allClasses);
allClasses = Sets.intersection(dictionary.getBoundClasses(), allClasses);
if (allClasses.isEmpty()) {
throw new IllegalArgumentException("None of the provided classes are exported by Elide");
}
Expand Down
2 changes: 1 addition & 1 deletion elide-contrib/elide-test-helpers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<artifactId>elide-contrib-parent-pom</artifactId>
<groupId>com.yahoo.elide</groupId>
<version>4.5.14-SNAPSHOT</version>
<version>5.0.0-pr7-SNAPSHOT</version>
</parent>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ public static Selection field(String name, Arguments arguments, SelectionSet...
return new Field(null, name, arguments, relayWrap(Arrays.asList(selectionSet)));
}

public static Selection field(String alias, String name, Arguments arguments, SelectionSet... selectionSet) {
return new Field(alias, name, arguments, relayWrap(Arrays.asList(selectionSet)));
}

/**
* Creates an attribute(scalar field) selection.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public String toGraphQLSpec() {

@Override
public String toResponse() {
if (selectionSet instanceof String) {
if (selectionSet instanceof String || selectionSet instanceof Number) {
// scalar response field
return String.format(
"\"%s\":%s",
Expand Down
Loading