-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Entity dictionary auto-scan for security checks and lifecycle hooks. (#…
…1108) * Added logic to scan classpath for elide checks and lifecycle hooks * Added unit tests * Added spring and standalone integration tests * Minor cleanup * Fixed legit codacy issues * Inspection rework * Minor cleanup * Fixed bug where we check for the wrong duplicate class * Fixing GraphQL Logging on ForbiddenAccessExceptions to match JSON-API (#1109) * Fixed checkstyle for multiple copyrights. Removed Hook annotation (it will be added in a different way in Elide 5).
- Loading branch information
Showing
22 changed files
with
414 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
elide-annotations/src/main/java/com/yahoo/elide/annotation/SecurityCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2018, the original author or authors. | ||
* Copyright 2019, Yahoo Inc. | ||
* Licensed under the Apache License, Version 2.0 | ||
* See LICENSE file in project root for terms. | ||
*/ | ||
package com.yahoo.elide.annotation; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* A convenience annotation that help you register elide check. | ||
* <br><br> | ||
* Example: <br> | ||
* <pre> | ||
* <code>@SecurityCheck("i am an expression")</code> | ||
* public static class{@literal Inline<Post>} extends{@literal OperationCheck<Post>} { | ||
* <code>@Override</code> | ||
* public boolean ok(Post object, RequestScope requestScope, | ||
* {@literal Optional<ChangeSpec>} changeSpec) { | ||
* return false; | ||
* } | ||
* } | ||
* </pre> | ||
* | ||
* <b>NOTE: </b> The class you annotated must be a {@link com.yahoo.elide.security.checks.Check}, | ||
* otherwise a RuntimeException is thrown. | ||
* | ||
* @author olOwOlo | ||
* | ||
* This class is based on https://github.com/illyasviel/elide-spring-boot/blob/master | ||
* /elide-spring-boot-autoconfigure/src/main/java/org/illyasviel/elide/spring/boot/annotation/ElideCheck.java | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@Documented | ||
public @interface SecurityCheck { | ||
|
||
/** | ||
* The expression which will be used for | ||
* {@link com.yahoo.elide.annotation.ReadPermission#expression()}, | ||
* {@link com.yahoo.elide.annotation.UpdatePermission#expression()}, | ||
* {@link com.yahoo.elide.annotation.CreatePermission#expression()}, | ||
* {@link com.yahoo.elide.annotation.DeletePermission#expression()}. | ||
* @return The expression you want to defined. | ||
*/ | ||
String value(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.