From da19ee6252adb8c49211b657730cac47b9e11ddf Mon Sep 17 00:00:00 2001 From: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Date: Tue, 2 May 2023 17:30:32 -0400 Subject: [PATCH] [Extensions] Introduce Identity Plugin to Core (#7246) * Identity and access control for OpenSearch Adding a new service and plugin interface that provides identity and access control inside of OpenSearch. This is the founding building block, see more high level thoughts here on our recent blog. https://opensearch.org/blog/Introducing-Identity/ The new extension point, IdentityPlugin, is added with IdentityService handling that plugin interface. IdentityService authenticates users and enables access control systems. Adding HTTP basic authentication in the RestController the default NoopIdentityPlugin changes no behavior. Signed-off-by: Stephen Crawford Signed-off-by: Peter Nied Co-authored-by: Peter Nied Co-authored-by: Andriy Redko --- .idea/inspectionProfiles/Project_Default.xml | 3 + CHANGELOG.md | 2 + gradle/missing-javadoc.gradle | 2 + plugins/identity-shiro/build.gradle | 67 ++++++ .../licenses/bcprov-jdk15on-1.70.jar.sha1 | 1 + .../licenses/bcprov-jdk15on-LICENSE.txt | 22 ++ .../licenses/bcprov-jdk15on-NOTICE.txt | 0 .../licenses/commons-beanutils-1.9.4.jar.sha1 | 1 + .../licenses/commons-beanutils-LICENSE.txt | 202 ++++++++++++++++++ .../licenses/commons-beanutils-NOTICE.txt | 5 + .../licenses/commons-lang-2.6.jar.sha1 | 1 + .../licenses/commons-lang-LICENSE.txt | 202 ++++++++++++++++++ .../licenses/commons-lang-NOTICE.txt | 5 + .../licenses/commons-logging-1.2.jar.sha1 | 1 + .../licenses/commons-logging-LICENSE.txt | 202 ++++++++++++++++++ .../licenses/commons-logging-NOTICE.txt | 5 + .../licenses/shiro-core-1.9.1.jar.sha1 | 1 + .../licenses/shiro-core-LICENSE.txt | 201 +++++++++++++++++ .../licenses/shiro-core-NOTICE.txt | 15 ++ .../licenses/slf4j-api-1.7.36.jar.sha1 | 1 + .../licenses/slf4j-api-LICENSE.txt | 21 ++ .../licenses/slf4j-api-NOTICE.txt | 0 .../identity/shiro/AuthTokenHandler.java | 37 ++++ .../identity/shiro/ShiroIdentityPlugin.java | 53 +++++ .../identity/shiro/ShiroSecurityManager.java | 38 ++++ .../identity/shiro/ShiroSubject.java | 91 ++++++++ .../shiro/UnsupportedAuthenticationToken.java | 12 ++ .../identity/shiro/package-info.java | 12 ++ .../shiro/realm/BCryptPasswordMatcher.java | 36 ++++ .../identity/shiro/realm/OpenSearchRealm.java | 144 +++++++++++++ .../opensearch/identity/shiro/realm/User.java | 54 +++++ .../identity/shiro/realm/package-info.java | 10 + .../plugin-metadata/plugin-security.policy | 11 + .../identity/shiro/AuthTokenHandlerTests.java | 62 ++++++ .../identity/shiro/ShiroSubjectTests.java | 74 +++++++ .../realm/BCryptPasswordMatcherTests.java | 45 ++++ .../shiro/realm/OpenSearchRealmTests.java | 39 ++++ qa/smoke-test-http/build.gradle | 3 +- .../http/IdentityAuthenticationIT.java | 91 ++++++++ .../replication/SegmentReplicationIT.java | 6 +- .../org/opensearch/action/ActionModule.java | 6 +- .../common/settings/FeatureFlagSettings.java | 1 + .../opensearch/common/util/FeatureFlags.java | 6 + .../opensearch/identity/IdentityService.java | 51 +++++ .../opensearch/identity/NamedPrincipal.java | 55 +++++ .../java/org/opensearch/identity/Subject.java | 32 +++ .../identity/noop/NoopIdentityPlugin.java | 32 +++ .../opensearch/identity/noop/NoopSubject.java | 57 +++++ .../identity/noop/package-info.java | 10 + .../org/opensearch/identity/package-info.java | 7 + .../opensearch/identity/tokens/AuthToken.java | 18 ++ .../identity/tokens/BasicAuthToken.java | 44 ++++ .../identity/tokens/RestTokenExtractor.java | 56 +++++ .../identity/tokens/package-info.java | 10 + .../main/java/org/opensearch/node/Node.java | 15 +- .../opensearch/plugins/IdentityPlugin.java | 26 +++ .../org/opensearch/rest/RestController.java | 50 ++++- .../opensearch/action/ActionModuleTests.java | 7 +- .../bootstrap/IdentityPluginTests.java | 36 ++++ .../extensions/ExtensionsManagerTests.java | 4 +- .../opensearch/rest/RestControllerTests.java | 25 ++- .../rest/RestHttpResponseHeadersTests.java | 11 +- .../indices/RestValidateQueryActionTests.java | 12 +- .../test/rest/RestActionTestCase.java | 12 +- 64 files changed, 2341 insertions(+), 20 deletions(-) create mode 100644 plugins/identity-shiro/build.gradle create mode 100644 plugins/identity-shiro/licenses/bcprov-jdk15on-1.70.jar.sha1 create mode 100644 plugins/identity-shiro/licenses/bcprov-jdk15on-LICENSE.txt create mode 100644 plugins/identity-shiro/licenses/bcprov-jdk15on-NOTICE.txt create mode 100644 plugins/identity-shiro/licenses/commons-beanutils-1.9.4.jar.sha1 create mode 100644 plugins/identity-shiro/licenses/commons-beanutils-LICENSE.txt create mode 100644 plugins/identity-shiro/licenses/commons-beanutils-NOTICE.txt create mode 100644 plugins/identity-shiro/licenses/commons-lang-2.6.jar.sha1 create mode 100644 plugins/identity-shiro/licenses/commons-lang-LICENSE.txt create mode 100644 plugins/identity-shiro/licenses/commons-lang-NOTICE.txt create mode 100644 plugins/identity-shiro/licenses/commons-logging-1.2.jar.sha1 create mode 100644 plugins/identity-shiro/licenses/commons-logging-LICENSE.txt create mode 100644 plugins/identity-shiro/licenses/commons-logging-NOTICE.txt create mode 100644 plugins/identity-shiro/licenses/shiro-core-1.9.1.jar.sha1 create mode 100644 plugins/identity-shiro/licenses/shiro-core-LICENSE.txt create mode 100644 plugins/identity-shiro/licenses/shiro-core-NOTICE.txt create mode 100644 plugins/identity-shiro/licenses/slf4j-api-1.7.36.jar.sha1 create mode 100644 plugins/identity-shiro/licenses/slf4j-api-LICENSE.txt create mode 100644 plugins/identity-shiro/licenses/slf4j-api-NOTICE.txt create mode 100644 plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/AuthTokenHandler.java create mode 100644 plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroIdentityPlugin.java create mode 100644 plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroSecurityManager.java create mode 100644 plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroSubject.java create mode 100644 plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/UnsupportedAuthenticationToken.java create mode 100644 plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/package-info.java create mode 100644 plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/realm/BCryptPasswordMatcher.java create mode 100644 plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/realm/OpenSearchRealm.java create mode 100644 plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/realm/User.java create mode 100644 plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/realm/package-info.java create mode 100644 plugins/identity-shiro/src/main/plugin-metadata/plugin-security.policy create mode 100644 plugins/identity-shiro/src/test/java/org/opensearch/identity/shiro/AuthTokenHandlerTests.java create mode 100644 plugins/identity-shiro/src/test/java/org/opensearch/identity/shiro/ShiroSubjectTests.java create mode 100644 plugins/identity-shiro/src/test/java/org/opensearch/identity/shiro/realm/BCryptPasswordMatcherTests.java create mode 100644 plugins/identity-shiro/src/test/java/org/opensearch/identity/shiro/realm/OpenSearchRealmTests.java create mode 100644 qa/smoke-test-http/src/test/java/org/opensearch/http/IdentityAuthenticationIT.java create mode 100644 server/src/main/java/org/opensearch/identity/IdentityService.java create mode 100644 server/src/main/java/org/opensearch/identity/NamedPrincipal.java create mode 100644 server/src/main/java/org/opensearch/identity/Subject.java create mode 100644 server/src/main/java/org/opensearch/identity/noop/NoopIdentityPlugin.java create mode 100644 server/src/main/java/org/opensearch/identity/noop/NoopSubject.java create mode 100644 server/src/main/java/org/opensearch/identity/noop/package-info.java create mode 100644 server/src/main/java/org/opensearch/identity/package-info.java create mode 100644 server/src/main/java/org/opensearch/identity/tokens/AuthToken.java create mode 100644 server/src/main/java/org/opensearch/identity/tokens/BasicAuthToken.java create mode 100644 server/src/main/java/org/opensearch/identity/tokens/RestTokenExtractor.java create mode 100644 server/src/main/java/org/opensearch/identity/tokens/package-info.java create mode 100644 server/src/main/java/org/opensearch/plugins/IdentityPlugin.java create mode 100644 server/src/test/java/org/opensearch/bootstrap/IdentityPluginTests.java diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 5cf789707c58c..ece87b3eed38a 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -2,6 +2,9 @@