forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42c6954
commit 5e5c257
Showing
9 changed files
with
86 additions
and
2 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
Empty file.
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,10 @@ | ||
apply plugin: 'elasticsearch.build' | ||
|
||
base { | ||
archivesName = 'elasticsearch-jose-wrapper' | ||
} | ||
|
||
dependencies { | ||
api "com.nimbusds:nimbus-jose-jwt:9.37.3" | ||
api project(':server') | ||
} |
12 changes: 12 additions & 0 deletions
12
x-pack/plugin/security/lib/jose-wrapper/src/main/java/module-info.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,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
module org.elasticsearch.jose { | ||
requires org.elasticsearch.server; | ||
requires com.nimbusds.jose.jwt; | ||
exports org.elasticsearch.jose; | ||
} |
39 changes: 39 additions & 0 deletions
39
...ck/plugin/security/lib/jose-wrapper/src/main/java/org/elasticsearch/jose/JoseWrapper.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,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.jose; | ||
|
||
import com.nimbusds.jwt.JWTClaimsSet; | ||
import com.nimbusds.jwt.SignedJWT; | ||
|
||
import org.elasticsearch.SpecialPermission; | ||
|
||
|
||
import java.security.AccessController; | ||
import java.security.PrivilegedAction; | ||
|
||
/** | ||
* This class wraps the operations requiring access in {@link AccessController#doPrivileged(PrivilegedAction)} blocks. | ||
* Can't do these operations inline with giving too much access due to how the security manager calculates the stack for lambda expressions. | ||
* Isolating the calls here allows for least privilege access to this helper jar. | ||
*/ | ||
public class JoseWrapper { | ||
|
||
// utility class | ||
private JoseWrapper() {} | ||
|
||
public static String getHeaderAsString(SignedJWT signedJWT) { | ||
SpecialPermission.check(); | ||
return AccessController.doPrivileged((PrivilegedAction<String>) () -> signedJWT.getHeader().toString()); | ||
|
||
} | ||
|
||
public static String getClaimsSetAsString(JWTClaimsSet jwtClaimsSet) { | ||
SpecialPermission.check(); | ||
return AccessController.doPrivileged((PrivilegedAction<String>) jwtClaimsSet::toString); | ||
} | ||
} |
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
2 changes: 2 additions & 0 deletions
2
x-pack/plugin/security/src/main/plugin-metadata/plugin-security.codebases
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
netty-common: io.netty.util.NettyRuntime | ||
netty-transport: io.netty.channel.Channel | ||
nimbus-jose-jwt: com.nimbusds.jose.shaded.gson.internal.ConstructorConstructor | ||
oauth2-oidc-sdk: com.nimbusds.jwt.SignedJWT |
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