Skip to content

Commit

Permalink
Added secure restclient, and other gradlew settings
Browse files Browse the repository at this point in the history
  • Loading branch information
skkosuri-amzn committed Aug 25, 2020
1 parent 3f11d53 commit ab091fc
Show file tree
Hide file tree
Showing 10 changed files with 918 additions and 55 deletions.
362 changes: 362 additions & 0 deletions .eclipseformat.xml

Large diffs are not rendered by default.

62 changes: 53 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,61 @@
## My Project
# Open Distro for Elasticsearch Common-Utils

TODO: Fill this README out!
Open Distro for Elasticsearch Common-Utils is focused on providing reusable Java components for Elasticsearch plugins.

Be sure to:
This library is composed of following parts:
1. SecureRestClientBuilder - provides methods to create secure low-level and high-level REST client. This is
useful to make secure REST calls to Elasticsearch or other plugin api's.
2. InjectSecurity - provides methods to inject user or roles. This is useful for running background jobs securely.

* Change the title in this README
* Edit your repository description on GitHub
Next:
3. IntegTestsWithSecurity - provides methods to create users, roles for running integ tests with security plugin.
4. Shared Request/Response/Action classes used for plugin to plugin transport layer calls.
5. Any common functionality across Elasticsearch plugins could be moved to this.

## Security

See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
## Setup

## License
1. Check out this package from version control.
1. Launch Intellij IDEA, choose **Import Project**, and select the `settings.gradle` file in the root of this package.
1. To build from the command line, set `JAVA_HOME` to point to a JDK >= 14 before running `./gradlew`.

This project is licensed under the Apache-2.0 License.

## Build
[todo]: how to publish this project jar to maven/jcenter



### Building from the command line
```
./gradlew clean
./gradlew build
./gradlew publishToMavenLocal
```

### Logging

To change loglevel, add below to `config/log4j2.properties` or use REST API to set.
```
logger.commons.name = com.amazon.opendistroforelasticsearch.commons
logger.commons.level = debug
```

## Code of Conduct

This project has adopted an [Open Source Code of Conduct](https://opendistro.github.io/for-elasticsearch/codeofconduct.html).


## Security issue notifications

If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public GitHub issue.


## Licensing

See the [LICENSE](./LICENSE.txt) file for our project's licensing. We will ask you to confirm the licensing of your contribution.


## Copyright

Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
87 changes: 87 additions & 0 deletions backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

buildscript {
ext {
es_group = "org.elasticsearch"
es_version = '7.8.0'
}

repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}

dependencies {
classpath "${es_group}.gradle:build-tools:${es_version}"
}
}

plugins {
id 'nebula.ospackage' version "8.3.0" apply false
id 'java-library'
id 'checkstyle'
id 'maven-publish'
}

repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}


group 'com.amazon.opendistroforelasticsearch.commons'


sourceCompatibility = 1.8

ext {
es_version = '7.8.0'
opendistroVersion = '1.9.0'
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}


apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'base'
apply plugin: 'jacoco'

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile "org.elasticsearch.client:elasticsearch-rest-high-level-client:${es_version}"
}


/*
spotless {
java {
removeUnusedImports()
importOrder 'java', 'javax', 'org', 'com'
licenseHeaderFile 'spotless.license.java'

eclipse().configFile rootProject.file('.eclipseformat.xml')
}
}*/
71 changes: 60 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,54 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

buildscript {
ext {
es_group = "org.elasticsearch"
es_version = '7.8.0'
opendistroVersion = '1.9.0'
}

repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}

dependencies {
classpath "${es_group}.gradle:build-tools:${es_version}"
}
}

plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id "com.diffplug.gradle.spotless" version "3.26.1"
}

repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}

group 'com.amazon.opendistroforelasticsearch.commons'
version '1.9.0.0'

sourceCompatibility = 1.8

ext {
es_version = '7.8.0'
}
version = "${opendistroVersion}.0"

publishing {
publications {
Expand All @@ -19,14 +57,25 @@ publishing {
}
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'base'
apply plugin: 'jacoco'


dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile "org.elasticsearch.client:elasticsearch-rest-high-level-client:${es_version}"
compile 'com.google.googlejavaformat:google-java-format:1.3'
}

spotless {
java {
removeUnusedImports()
importOrder 'java', 'javax', 'org', 'com'
licenseHeaderFile 'spotless.license.java'

eclipse().configFile rootProject.file('.eclipseformat.xml')
}
}
15 changes: 15 additions & 0 deletions spotless.license.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package com.amazon.opendistroforelasticsearch.commons;

public class ConfigConstants {
Expand All @@ -11,9 +26,9 @@ public class ConfigConstants {
public static final String CONTENT_TYPE_DEFAULT = "application/json";
public static final String AUTHORIZATION = "authorization";

//These reside in security plugin.
// These reside in security plugin.
public static final String OPENDISTRO_SECURITY_INJECTED_ROLES = "opendistro_security_injected_roles";
public static final String INJECTED_USER = "injected_user";
public static final String OPENDISTRO_SECURITY_USE_INJECTED_USER_DEFAULT = "false";
public static final String OPENDISTRO_SECURITY_USE_INJECTED_USER_FOR_PLUGINS = "opendistro_security_use_injected_user_for_plugins";
public static final String OPENDISTRO_SECURITY_SSL_HTTP_ENABLED = "opendistro_security.ssl.http.enabled";
}
Loading

0 comments on commit ab091fc

Please sign in to comment.