From fc075f555a2de91d86ab80f41efcc15ca4761f3c Mon Sep 17 00:00:00 2001 From: Jared Whiklo Date: Mon, 10 Feb 2020 10:13:17 -0600 Subject: [PATCH] Prepare for 1.1.0 release (#22) * Preparing for next development iteration * Update CONTRIBUTING.md (#15) * Fix typo: s/contraint/constraint * Ran Aspell CLI spell checker (#17) I used an Aspell "word list" based on the "word list" from the ISLE repo found here... https://raw.githubusercontent.com/Islandora-Collaboration-Group/ISLE/master/.aspell.en.pws * Update README for CLAWdit (#16) * Update README.md * Update README.md * Update README.md Nothing left but the playbook! * 'The string "claw" was not found' or - COMPLETE DECLAW #1267 #1314 (#18) * Update CONTRIBUTING.md * Update README.md * Update README.md * Update PULL_REQUEST_TEMPLATE.md (#19) * Moves maven URL to https (#21) fixes: https://github.com/Islandora/documentation/issues/1415 * Add a disable switch to the config XML (#20) Co-authored-by: dannylamb Co-authored-by: Melissa Anez Co-authored-by: J Hunt Co-authored-by: Yamil Co-authored-by: B. Seeger --- .github/PULL_REQUEST_TEMPLATE.md | 4 +- CONTRIBUTING.md | 20 +-- README.md | 46 +++-- build.gradle | 4 +- .../ca/islandora/syn/settings/Config.java | 9 + .../java/ca/islandora/syn/valve/SynValve.java | 4 +- .../settings/SettingsParserEnabledTest.java | 159 ++++++++++++++++++ 7 files changed, 216 insertions(+), 30 deletions(-) create mode 100644 src/test/java/ca/islandora/syn/settings/SettingsParserEnabledTest.java diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 637199f..44f3d2d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,7 +14,7 @@ A in-depth description of the changes made by this PR. Technical details and pos * Removed y * Does this change require documentation to be updated? * Does this change add any new dependencies? -* Does this change require any other modifications to be made to the repository (ie. Regeneration activity, etc.)? +* Does this change require any other modifications to be made to the repository (i.e. Regeneration activity, etc.)? * Could this change impact execution of existing code? # How should this be tested? @@ -29,4 +29,4 @@ A description of what steps someone could take to: Any additional information that you think would be helpful when reviewing this PR. # Interested parties -Tag (@ mention) interested parties or, if unsure, @Islandora-CLAW/committers \ No newline at end of file +Tag (@ mention) interested parties or, if unsure, @Islandora/8-x-committers diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c5dd0d..3ee404a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,26 +1,26 @@ # Welcome! -If you are reading this document then you are interested in contributing to the Islandora CLAW. All contributions are welcome: use-cases, documentation, code, patches, bug reports, feature requests, etc. You do not need to be a programmer to speak up! +If you are reading this document then you are interested in contributing to Islandora 8. All contributions are welcome: use-cases, documentation, code, patches, bug reports, feature requests, etc. You do not need to be a programmer to speak up! ## Workflows -The group meets each Wednesday at 1:00 PM Eastern. Meeting notes and announcements are posted to the [Islandora community list](https://groups.google.com/forum/#!forum/islandora) and the [Islandora developers list](https://groups.google.com/forum/#!forum/islandora-dev). You can view meeting agendas, notes, and call-in information [here](https://github.com/Islandora-CLAW/CLAW/wiki#islandora-claw-tech-calls). Anybody is welcome to join the calls, and add items to the agenda. +The group meets each Wednesday at 1:00 PM Eastern. Meeting notes and announcements are posted to the [Islandora community list](https://groups.google.com/forum/#!forum/islandora) and the [Islandora developers list](https://groups.google.com/forum/#!forum/islandora-dev). You can view meeting agendas, notes, and call-in information [here](https://github.com/Islandora/documentation/wiki#islandora-8-tech-calls). Anybody is welcome to join the calls, and add items to the agenda. ### Use cases -If you would like to submit a use case to the Islandora CLAW project, please submit an issue [here](https://github.com/Islandora-CLAW/CLAW/issues/new) using the [Use Case template](https://github.com/Islandora-CLAW/CLAW/wiki/Use-Case-template), prepending "Use Case:" to the title of the issue. +If you would like to submit a use case to the Islandora 8 project, please submit an issue [here](https://github.com/Islandora/documentation/issues/new) using the [Use Case template](https://github.com/Islandora/documentation/wiki/Use-Case-template), prepending "Use Case:" to the title of the issue. ### Documentation -You can contribute documentation in two different ways. One way is to create an issue [here](https://github.com/Islandora-CLAW/CLAW/issues/new), prepending "Documentation:" to the title of the issue. Another way is by pull request, which is the same process as [Contribute Code](https://github.com/Islandora-CLAW/CLAW/blob/master/CONTRIBUTING.md#contribute-code). All documentation resides in [`docs`](https://github.com/Islandora-CLAW/CLAW/tree/master/docs). +You can contribute documentation in two different ways. One way is to create an issue [here](https://github.com/Islandora/documentation/issues/new), prepending "Documentation:" to the title of the issue. Another way is by pull request, which is the same process as [Contribute Code](https://github.com/Islandora/documentation/blob/master/CONTRIBUTING.md#contribute-code). All documentation resides in [`docs`](https://github.com/Islandora/documentation/tree/master/docs). ### Request a new feature -To request a new feature you should [open an issue in the CLAW repository](https://github.com/Islandora-CLAW/CLAW/issues/new) or create a use case (see the _Use cases_ section above), and summarize the desired functionality. Prepend "Enhancement:" if creating an issue on the project repo, and "Use Case:" if creating a use case. +To request a new feature you should [open an issue in the Islandora 8 repository](https://github.com/Islandora/documentation/issues/new) or create a use case (see the _Use cases_ section above), and summarize the desired functionality. Prepend "Enhancement:" if creating an issue on the project repo, and "Use Case:" if creating a use case. ### Report a bug -To report a bug you should [open an issue in the CLAW repository](https://github.com/Islandora-CLAW/CLAW/issues/new) that summarizes the bug. Prepend the label "Bug:" to the title of the issue. +To report a bug you should [open an issue in the Islandora 8 repository](https://github.com/Islandora/documentation/issues/new) that summarizes the bug. Prepend the label "Bug:" to the title of the issue. In order to help us understand and fix the bug it would be great if you could provide us with: @@ -36,11 +36,11 @@ That is great! In this case please send us a pull request as described in the se ### Contribute code -Before you set out to contribute code you will need to have completed a [Contributor License Agreement](http://islandora.ca/sites/default/files/islandora_cla.pdf) or be covered by a [Corporate Contributor Licencse Agreement](http://islandora.ca/sites/default/files/islandora_ccla.pdf). The signed copy of the license agreement should be sent to +Before you set out to contribute code you will need to have completed a [Contributor License Agreement](http://islandora.ca/sites/default/files/islandora_cla.pdf) or be covered by a [Corporate Contributor License Agreement](http://islandora.ca/sites/default/files/islandora_ccla.pdf). The signed copy of the license agreement should be sent to _If you are interested in contributing code to Islandora but do not know where to begin:_ -In this case you should [browse open issues](https://github.com/Islandora-CLAW/CLAW/issues) and check out [use cases](https://github.com/Islandora-CLAW/CLAW/labels/use%20case). +In this case you should [browse open issues](https://github.com/Islandora/documentation/issues) and check out [use cases](https://github.com/Islandora/documentation/labels/use%20case). If you are contributing Drupal code, it must adhere to [Drupal Coding Standards](https://www.drupal.org/coding-standards); Travis CI will check for this on pull requests. @@ -49,7 +49,7 @@ Contributions to the Islandora codebase should be sent as GitHub pull requests. * For _small patches_, feel free to submit pull requests directly for those patches. * For _larger code contributions_, please use the following process. The idea behind this process is to prevent any wasted work and catch design issues early on. - 1. [Open an issue](https://github.com/Islandora-CLAW/CLAW/issues), prepending "Enhancement:" in the title if a similar issue does not exist already. If a similar issue does exist, then you may consider participating in the work on the existing issue. + 1. [Open an issue](https://github.com/Islandora/documentation/issues/new), prepending "Enhancement:" in the title if a similar issue does not exist already. If a similar issue does exist, then you may consider participating in the work on the existing issue. 2. Comment on the issue with your plan for implementing the issue. Explain what pieces of the codebase you are going to touch and how everything is going to fit together. 3. Islandora committers will work with you on the design to make sure you are on the right track. 4. Implement your issue, create a pull request (see below), and iterate from there. @@ -60,7 +60,7 @@ Take a look at [Creating a pull request](https://help.github.com/articles/creati 1. [Fork](https://help.github.com/articles/fork-a-repo) this repository to your personal or institutional GitHub account (depending on the CLA you are working under). Be cautious of which branches you work from though (you'll want to base your work off master, or for Drupal modules use the most recent version branch). See [Fork a repo](https://help.github.com/articles/fork-a-repo) for detailed instructions. 2. Commit any changes to your fork. -3. Send a [pull request](https://help.github.com/articles/creating-a-pull-request) using the [pull request template](https://github.com/Islandora-CLAW/CLAW/blob/master/.github/PULL_REQUEST_TEMPLATE.md) to the Islandora GitHub repository that you forked in step 1. If your pull request is related to an existing issue -- for instance, because you reported a [bug/issue](https://github.com/Islandora-CLAW/CLAW/issues) earlier -- prefix the title of your pull request with the corresponding issue number (e.g. `issue-123: ...`). Please also include a reference to the issue in the description of the pull. This can be done by using '#' plus the issue number like so '#123', also try to pick an appropriate name for the branch in which you're issuing the pull request from. +3. Send a [pull request](https://help.github.com/articles/creating-a-pull-request) using the [pull request template](https://github.com/Islandora/documentation/blob/master/.github/PULL_REQUEST_TEMPLATE.md) to the Islandora GitHub repository that you forked in step 1. If your pull request is related to an existing issue -- for instance, because you reported a [bug/issue](https://github.com/Islandora/documentation/issues) earlier -- prefix the title of your pull request with the corresponding issue number (e.g. `issue-123: ...`). Please also include a reference to the issue in the description of the pull. This can be done by using '#' plus the issue number like so '#123', also try to pick an appropriate name for the branch in which you're issuing the pull request from. You may want to read [Syncing a fork](https://help.github.com/articles/syncing-a-fork) for instructions on how to keep your fork up to date with the latest changes of the upstream (official) repository. diff --git a/README.md b/README.md index 39219bb..8bcbfea 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,21 @@ # ![Syn](https://cloud.githubusercontent.com/assets/2371345/23724175/2998ecb0-0422-11e7-9009-aee3f129633f.png) Syn -[![Build Status](https://travis-ci.com/Islandora-CLAW/Syn.svg?branch=master)](https://travis-ci.com/Islandora-CLAW/Syn) +[![Build Status](https://travis-ci.com/Islandora/Syn.svg?branch=master)](https://travis-ci.com/Islandora/Syn) [![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md) [![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](./LICENSE) -[![codecov](https://codecov.io/gh/Islandora-CLAW/Syn/branch/master/graph/badge.svg)](https://codecov.io/gh/Islandora-CLAW/Syn) +[![codecov](https://codecov.io/gh/Islandora/Syn/branch/master/graph/badge.svg)](https://codecov.io/gh/Islandora/Syn) -## Description +## Introduction -A valve for Tomcat8 that authenticates the JWT tokens created by Islandora in order to provide sessionless Authentication for Fedora4. Named after the Norse goddess [Syn](https://en.wikipedia.org/wiki/Syn_(goddess)). +A valve for Tomcat8 that authenticates the JWT tokens created by Islandora in order to provide sessionless Authentication for Fedora. Named after the Norse goddess [Syn](https://en.wikipedia.org/wiki/Syn_(goddess)). -## Building +## Requirements This project requires Java 8 and can be built with [Gradle](https://gradle.org). To build and test locally, use `./gradlew build`. -## Installing +## Installation ### Copy Syn JAR -Copy the JAR that was built above from `build/libs/islandora-syn-X.X.X-all.jar` and place into `$TOMCAT_HOME/lib` directory. Can be found in Ubuntu at: `/var/lib/tomcat8/lib/`. Note that this JAR is built to contain all the dependancies. +Copy the JAR that was built above from `build/libs/islandora-syn-X.X.X-all.jar` and place into `$TOMCAT_HOME/lib` directory. Can be found in Ubuntu at: `/var/lib/tomcat8/lib/`. Note that this JAR is built to contain all the dependencies. ### Register Valve Now register the valve in Tomcat configuration file. @@ -29,8 +29,8 @@ In Ubuntu this file is located at: `/var/lib/tomcat8/conf/context.xml` where: * ***pathname***: The location of the settings file. Defaults to `$CATALINA_BASE/conf/syn-settings.xml`. -### Enable `security-contraint` -The valve checks if requested url is under **security contraints**. So, valve will activate only if the Fedora4 *web.xml* file contains something like: +### Enable `security-constraint` +The valve checks if requested URL is under **security constraints**. So, valve will activate only if the Fedora4 *web.xml* file contains something like: ```xml @@ -54,7 +54,7 @@ The valve checks if requested url is under **security contraints**. So, valve wi ``` -On ubuntu this file can be found at: +On Ubuntu this file can be found at: `/var/lib/tomcat8/webapps/fcrepo/WEB-INF/web.xml` ### Setup Syn Configuration @@ -63,16 +63,32 @@ Modify the [example configuration](./conf/syn-settings.example.xml) and move it ### Header principals Additional roles are passed to Fedora via a HTTP header, this is configured via the `header` attribute to the `` element in the syn-settings.xml.example file. You must also configure Fedora to read this header via its HeaderProvider. +## Documentation + +Further documentation for this module is available on the [Islandora 8 documentation site](https://islandora.github.io/documentation/). + +## Troubleshooting/Issues + +Having problems or solved a problem? Check out the Islandora google groups for a solution. + +* [Islandora Group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/islandora) +* [Islandora Dev Group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/islandora-dev) + ## Maintainers -* [Jonathan Green](https://github.com/jonathangreen/) +Current maintainers: + +* [Jared Whiklo](https://github.com/whikloj) + ## Development -If you would like to contribute, please get involved by attending our weekly [Tech Call](https://github.com/Islandora-CLAW/CLAW/wiki). We love to hear from you! +If you would like to contribute, please get involved by attending our weekly [Tech Call](https://github.com/islandora/documentation/wiki). We love to hear from you! + +If you would like to contribute code to the project, you need to be covered by an Islandora Foundation [Contributor License Agreement](http://islandora.ca/sites/default/files/islandora_cla.pdf) or [Corporate Contributor License Agreement](http://islandora.ca/sites/default/files/islandora_ccla.pdf). Please see the [Contributors](http://islandora.ca/resources/contributors) pages on Islandora.ca for more information. -If you would like to contribute code to the project, you need to be covered by an Islandora Foundation [Contributor License Agreement](http://islandora.ca/sites/default/files/islandora_cla.pdf) or [Corporate Contributor Licencse Agreement](http://islandora.ca/sites/default/files/islandora_ccla.pdf). Please see the [Contributors](http://islandora.ca/resources/contributors) pages on Islandora.ca for more information. +We recommend using the [islandora-playbook](https://github.com/Islandora-Devops/islandora-playbook) to get started. -## Licensing +## License -MIT +[MIT](/LICENSE.txt) diff --git a/build.gradle b/build.gradle index 1834057..afeecf0 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'jacoco' apply plugin: 'com.github.johnrengelman.shadow' def projectName = 'islandora-syn' -def projectVersion = '1.0.0' +def projectVersion = '1.0.1-SNAPSHOT' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -20,7 +20,7 @@ checkstyle { } repositories { - maven { url "http://repo.maven.apache.org/maven2" } + maven { url "https://repo.maven.apache.org/maven2" } } dependencies { diff --git a/src/main/java/ca/islandora/syn/settings/Config.java b/src/main/java/ca/islandora/syn/settings/Config.java index 474d3a1..35f340d 100644 --- a/src/main/java/ca/islandora/syn/settings/Config.java +++ b/src/main/java/ca/islandora/syn/settings/Config.java @@ -6,6 +6,7 @@ public class Config { private int version = -1; private String header = ""; + private boolean disabled = false; private final List sites = new ArrayList<>(); private final List tokens = new ArrayList<>(); @@ -37,4 +38,12 @@ public void setHeader(final String header) { public String getHeader() { return this.header; } + + public void setDisabled(final String disabled) { + this.disabled = Boolean.parseBoolean(disabled); + } + + public boolean getDisabled() { + return this.disabled; + } } diff --git a/src/main/java/ca/islandora/syn/valve/SynValve.java b/src/main/java/ca/islandora/syn/valve/SynValve.java index c68bb62..477b30b 100644 --- a/src/main/java/ca/islandora/syn/valve/SynValve.java +++ b/src/main/java/ca/islandora/syn/valve/SynValve.java @@ -46,6 +46,7 @@ public class SynValve extends ValveBase { private Map staticTokenMap = null; private Map anonymousGetMap = null; private String roleHeader = null; + private boolean isDisabled = false; @Override public void invoke(final Request request, final Response response) @@ -54,7 +55,7 @@ public void invoke(final Request request, final Response response) final SecurityConstraint[] constraints = this.container.getRealm() .findSecurityConstraints(request, request.getContext()); - if ((constraints == null + if (this.isDisabled || (constraints == null && !request.getContext().getPreemptiveAuthentication()) || !hasAuthConstraint(constraints)) { this.getNext().invoke(request, response); @@ -301,6 +302,7 @@ public synchronized void startInternal() throws LifecycleException { this.staticTokenMap = SettingsParser.getSiteStaticTokens(sites); this.anonymousGetMap = SettingsParser.getSiteAllowAnonymous(sites); this.roleHeader = sites.getHeader(); + this.isDisabled = sites.getDisabled(); } catch (final Exception e) { throw new LifecycleException("Error parsing XML Configuration", e); } diff --git a/src/test/java/ca/islandora/syn/settings/SettingsParserEnabledTest.java b/src/test/java/ca/islandora/syn/settings/SettingsParserEnabledTest.java new file mode 100644 index 0000000..888ebde --- /dev/null +++ b/src/test/java/ca/islandora/syn/settings/SettingsParserEnabledTest.java @@ -0,0 +1,159 @@ +package ca.islandora.syn.settings; + +import static junit.framework.TestCase.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.junit.Test; + +public class SettingsParserEnabledTest { + + @Test + public void testConfigDisabledUpper() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertTrue(settings.getDisabled()); + } + + @Test + public void testConfigDisabledLower() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertTrue(settings.getDisabled()); + } + + @Test + public void testConfigDisabledProper() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertTrue(settings.getDisabled()); + } + + @Test + public void testConfigDisabledCrazy() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertTrue(settings.getDisabled()); + } + + @Test + public void testConfigEnabledUpper() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertFalse(settings.getDisabled()); + } + + @Test + public void testConfigEnabledLower() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertFalse(settings.getDisabled()); + } + + @Test + public void testConfigEnabledProper() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertFalse(settings.getDisabled()); + } + + + @Test + public void testConfigEnabledCrazy() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertFalse(settings.getDisabled()); + } + + + @Test + public void testConfigEnabledOther() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertFalse(settings.getDisabled()); + } + + + @Test + public void testConfigEnabledBlank() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertFalse(settings.getDisabled()); + } + + + @Test + public void testConfigEnabledMissing() throws Exception { + final String testXml = String.join("\n" + , "" + , " " + , "" + ); + + final InputStream stream = new ByteArrayInputStream(testXml.getBytes()); + final Config settings = SettingsParser.getSitesObject(stream); + assertFalse(settings.getDisabled()); + } +}