Skip to content

Commit 0ca60c6

Browse files
gwbrownjakelandis
andauthored
Update OAuth2 OIDC SDK (#108799)
This commit updates the Nimbus OAuth2 OIDC SDK and the associated Nimbus JOSE+JWT, however a few odd choices had to be made in the process. First, we update to versions which are old at time of merge. This is because versions of Nimbus JOSE+JWT 9.38 and after through time of writing [contain a bug](https://bitbucket.org/connect2id/nimbus-jose-jwt/issues/550/java-module-doesnt-work-properly-with) in which the shaded gson class files included in the library are not properly loaded by our module loading code (and possibly in general? the root cause of the bug is unclear at time of writing but it does not appear to be present in all uses of this library). This requires us to use an older version of Nimbus OAuth2 OIDC SDK as well. Second, the aforementioned shaded gson uses reflection internally, and is used in unpredictable places in these libraries (e.g. constructors). This is extremely unfriendly to our usage of the security manager. In order to make the scope of permission grants as narrow as possible, we shadow nimbus-jose-jwt in order to insert `AccessController.doPrivileged` calls at the appropriate points, given the usage of gson is relatively contained. This approach was chosen over other approaches given 1) the relative simplicity given the implementation of the library, and 2) the complexity involved in safely using the library any other way - as one example, gson is used frequently in `toString()` methods, which are frequently called implicitly, especially in combination with logging which may mask security manager exceptions from being surfaced in tests. All of the code we intercept should be re-evaluated when this library is next upgraded. Co-authored-by: Jake Landis <[email protected]>
1 parent e7518fb commit 0ca60c6

File tree

16 files changed

+711
-139
lines changed

16 files changed

+711
-139
lines changed

gradle/verification-metadata.xml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,11 @@
946946
<sha256 value="fbfd0d5f2b2f86758b821daa5e79b5d7c965edd9dc1b2cc80b515df1c6ddc22d" origin="Generated by Gradle"/>
947947
</artifact>
948948
</component>
949-
<component group="com.nimbusds" name="nimbus-jose-jwt" version="9.23">
950-
<artifact name="nimbus-jose-jwt-9.23.jar">
951-
<sha256 value="33ab8084fdae1d75be1b061b1489d4a12045bd7b50c2e24ff152911e4551ec07" origin="Generated by Gradle"/>
949+
<component group="com.nimbusds" name="nimbus-jose-jwt" version="9.37.3">
950+
<artifact name="nimbus-jose-jwt-9.37.3.jar">
951+
<sha256 value="12ae4a3a260095d7aeba2adea7ae396e8b9570db8b7b409e09a824c219cc0444" origin="Generated by Gradle">
952+
<also-trust value="afc63b689d881439b95f343b1dca750391edac63b87392be4d90d19c94ccafbe"/>
953+
</sha256>
952954
</artifact>
953955
</component>
954956
<component group="com.nimbusds" name="nimbus-jose-jwt" version="9.37.3">
@@ -961,6 +963,11 @@
961963
<sha256 value="7664cf8c6f2adadf600287812b32878277beda54912eab9d4c2932cd50cb704a" origin="Generated by Gradle"/>
962964
</artifact>
963965
</component>
966+
<component group="com.nimbusds" name="oauth2-oidc-sdk" version="11.10.1">
967+
<artifact name="oauth2-oidc-sdk-11.10.1.jar">
968+
<sha256 value="9e51b2c17503cdd3eb97f41491c712aff7783bb3c67185d789f44ccf2a603b26" origin="Generated by Gradle"/>
969+
</artifact>
970+
</component>
964971
<component group="com.nimbusds" name="oauth2-oidc-sdk" version="11.9.1">
965972
<artifact name="oauth2-oidc-sdk-11.9.1.jar">
966973
<sha256 value="0820c9690966304d075347b88e81ae490213440fc4d2c84f3d370d41941b2b9c" origin="Generated by Gradle"/>
@@ -1739,6 +1746,11 @@
17391746
<sha256 value="64072f56d9dff5040b2acec477c5d5e6bcebfc88c508f12acb26072d07942146" origin="Generated by Gradle"/>
17401747
</artifact>
17411748
</component>
1749+
<component group="net.minidev" name="json-smart" version="2.5.1">
1750+
<artifact name="json-smart-2.5.1.jar">
1751+
<sha256 value="86c0c189581b79b57b0719f443a724e9f628ffbb9eef645cf79194f5973a1001" origin="Generated by Gradle"/>
1752+
</artifact>
1753+
</component>
17421754
<component group="net.minidev" name="json-smart" version="2.5.0">
17431755
<artifact name="json-smart-2.5.0.jar">
17441756
<sha256 value="432b9e545848c4141b80717b26e367f83bf33f19250a228ce75da6e967da2bc7" origin="Generated by Gradle"/>

x-pack/plugin/security/build.gradle

Lines changed: 125 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,19 @@ dependencies {
7979
runtimeOnly "joda-time:joda-time:2.10.10"
8080

8181
// Dependencies for oidc
82-
api "com.nimbusds:oauth2-oidc-sdk:9.37"
83-
api "com.nimbusds:nimbus-jose-jwt:9.23"
82+
api "com.nimbusds:oauth2-oidc-sdk:11.10.1"
83+
api project(path: xpackModule('security:lib:nimbus-jose-jwt-modified'), configuration: 'shadow')
84+
if (isEclipse) {
85+
/*
86+
* Eclipse can't pick up the shadow dependency so we point it at the unmodified version of the library
87+
* so it can compile things.
88+
*/
89+
api "com.nimbusds:nimbus-jose-jwt:9.37.3"
90+
}
8491
api "com.nimbusds:lang-tag:1.4.4"
8592
api "com.sun.mail:jakarta.mail:1.6.3"
8693
api "net.jcip:jcip-annotations:1.0"
87-
api "net.minidev:json-smart:2.4.10"
94+
api "net.minidev:json-smart:2.5.1"
8895
api "net.minidev:accessors-smart:2.4.2"
8996
api "org.ow2.asm:asm:8.0.1"
9097

@@ -103,7 +110,6 @@ dependencies {
103110
testImplementation('org.apache.kerby:kerb-crypto:1.1.1')
104111
testImplementation('org.apache.kerby:kerb-util:1.1.1')
105112
testImplementation('org.apache.kerby:token-provider:1.1.1')
106-
testImplementation('com.nimbusds:nimbus-jose-jwt:9.23')
107113
testImplementation('net.jcip:jcip-annotations:1.0')
108114
testImplementation('org.apache.kerby:kerb-admin:1.1.1')
109115
testImplementation('org.apache.kerby:kerb-server:1.1.1')
@@ -225,6 +231,9 @@ tasks.named("thirdPartyAudit").configure {
225231
'javax.servlet.http.HttpSession',
226232
'javax.servlet.http.HttpUpgradeHandler',
227233
'javax.servlet.http.Part',
234+
'jakarta.servlet.ServletRequest',
235+
'jakarta.servlet.http.HttpServletRequest',
236+
'jakarta.servlet.http.HttpServletResponse',
228237
// [missing classes] Shibboleth + OpenSAML have velocity support that we don't use
229238
'org.apache.velocity.VelocityContext',
230239
'org.apache.velocity.app.VelocityEngine',
@@ -274,112 +283,103 @@ tasks.named("thirdPartyAudit").configure {
274283
// [missing classes] Http Client cache has optional ehcache support
275284
'net.sf.ehcache.Ehcache',
276285
'net.sf.ehcache.Element',
277-
// Bouncycastle is an optional dependency for apache directory, cryptacular and opensaml packages. We
278-
// acknowledge them here instead of adding bouncy castle as a compileOnly dependency
279-
'org.bouncycastle.asn1.ASN1Encodable',
280-
'org.bouncycastle.asn1.ASN1InputStream',
281-
'org.bouncycastle.asn1.ASN1Integer',
282-
'org.bouncycastle.asn1.ASN1ObjectIdentifier',
283-
'org.bouncycastle.asn1.ASN1OctetString',
284-
'org.bouncycastle.asn1.ASN1Primitive',
285-
'org.bouncycastle.asn1.ASN1Sequence',
286-
'org.bouncycastle.asn1.ASN1TaggedObject',
287-
// 'org.bouncycastle.asn1.DEROctetString',
288-
'org.bouncycastle.asn1.pkcs.EncryptedPrivateKeyInfo',
289-
'org.bouncycastle.asn1.pkcs.EncryptionScheme',
290-
'org.bouncycastle.asn1.pkcs.KeyDerivationFunc',
291-
'org.bouncycastle.asn1.pkcs.PBEParameter',
292-
'org.bouncycastle.asn1.pkcs.PBES2Parameters',
293-
'org.bouncycastle.asn1.pkcs.PBKDF2Params',
294-
'org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers',
295-
'org.bouncycastle.asn1.pkcs.PrivateKeyInfo',
296-
'org.bouncycastle.asn1.x500.AttributeTypeAndValue',
297-
'org.bouncycastle.asn1.x500.RDN',
298-
'org.bouncycastle.asn1.x500.X500Name',
299-
'org.bouncycastle.asn1.x509.AccessDescription',
300-
'org.bouncycastle.asn1.x509.AlgorithmIdentifier',
301-
'org.bouncycastle.asn1.x509.AuthorityKeyIdentifier',
302-
'org.bouncycastle.asn1.x509.BasicConstraints',
303-
'org.bouncycastle.asn1.x509.DistributionPoint',
304-
'org.bouncycastle.asn1.x509.Extension',
305-
'org.bouncycastle.asn1.x509.GeneralName',
306-
'org.bouncycastle.asn1.x509.GeneralNames',
307-
'org.bouncycastle.asn1.x509.GeneralNamesBuilder',
308-
'org.bouncycastle.asn1.x509.KeyPurposeId',
309-
'org.bouncycastle.asn1.x509.KeyUsage',
310-
'org.bouncycastle.asn1.x509.PolicyInformation',
311-
'org.bouncycastle.asn1.x509.SubjectKeyIdentifier',
312-
'org.bouncycastle.asn1.x509.SubjectPublicKeyInfo',
313-
// 'org.bouncycastle.asn1.x9.DomainParameters',
314-
// 'org.bouncycastle.asn1.x9.ECNamedCurveTable',
315-
'org.bouncycastle.asn1.x9.X9ECParameters',
316-
'org.bouncycastle.cert.X509v3CertificateBuilder',
317-
'org.bouncycastle.cert.jcajce.JcaX509CertificateConverter',
318-
'org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils',
319-
'org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder',
320-
'org.bouncycastle.crypto.BlockCipher',
321-
'org.bouncycastle.crypto.BufferedBlockCipher',
322-
'org.bouncycastle.crypto.CipherParameters',
323-
'org.bouncycastle.crypto.Digest',
324-
'org.bouncycastle.crypto.PBEParametersGenerator',
325-
'org.bouncycastle.crypto.StreamCipher',
326-
'org.bouncycastle.crypto.agreement.kdf.ConcatenationKDFGenerator',
327-
// 'org.bouncycastle.crypto.ec.CustomNamedCurves',
328-
'org.bouncycastle.crypto.engines.AESEngine',
329-
'org.bouncycastle.crypto.generators.BCrypt',
330-
'org.bouncycastle.crypto.generators.OpenSSLPBEParametersGenerator',
331-
'org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator',
332-
'org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator',
333-
'org.bouncycastle.crypto.macs.HMac',
334-
'org.bouncycastle.crypto.modes.AEADBlockCipher',
335-
'org.bouncycastle.crypto.modes.GCMBlockCipher',
336-
'org.bouncycastle.crypto.paddings.BlockCipherPadding',
337-
'org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher',
338-
'org.bouncycastle.crypto.params.AsymmetricKeyParameter',
339-
'org.bouncycastle.crypto.params.DSAKeyParameters',
340-
'org.bouncycastle.crypto.params.DSAParameters',
341-
'org.bouncycastle.crypto.params.DSAPrivateKeyParameters',
342-
'org.bouncycastle.crypto.params.DSAPublicKeyParameters',
343-
'org.bouncycastle.crypto.params.ECDomainParameters',
344-
'org.bouncycastle.crypto.params.ECKeyParameters',
345-
'org.bouncycastle.crypto.params.ECPrivateKeyParameters',
346-
'org.bouncycastle.crypto.params.ECPublicKeyParameters',
347-
// 'org.bouncycastle.crypto.params.KDFParameters',
348-
'org.bouncycastle.crypto.params.KeyParameter',
349-
'org.bouncycastle.crypto.params.RSAKeyParameters',
350-
'org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters',
351-
'org.bouncycastle.crypto.prng.EntropySource',
352-
'org.bouncycastle.crypto.prng.SP800SecureRandom',
353-
'org.bouncycastle.crypto.prng.SP800SecureRandomBuilder',
354-
'org.bouncycastle.crypto.prng.drbg.SP80090DRBG',
355-
'org.bouncycastle.crypto.signers.DSASigner',
356-
'org.bouncycastle.crypto.signers.ECDSASigner',
357-
'org.bouncycastle.crypto.signers.RSADigestSigner',
358-
'org.bouncycastle.crypto.util.PrivateKeyFactory',
359-
'org.bouncycastle.crypto.util.PrivateKeyInfoFactory',
360-
'org.bouncycastle.crypto.util.PublicKeyFactory',
361-
'org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory',
362-
'org.bouncycastle.jcajce.provider.asymmetric.dsa.KeyPairGeneratorSpi',
363-
'org.bouncycastle.jcajce.provider.asymmetric.ec.KeyPairGeneratorSpi$EC',
364-
'org.bouncycastle.jcajce.provider.asymmetric.rsa.KeyPairGeneratorSpi',
365-
'org.bouncycastle.jcajce.provider.asymmetric.util.EC5Util',
366-
'org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil',
367-
// 'org.bouncycastle.jce.ECNamedCurveTable',
368-
// 'org.bouncycastle.jce.spec.ECNamedCurveParameterSpec',
369-
'org.bouncycastle.math.ec.ECFieldElement',
370-
'org.bouncycastle.math.ec.ECPoint',
371-
'org.bouncycastle.openssl.jcajce.JcaPEMWriter',
372-
'org.bouncycastle.operator.jcajce.JcaContentSignerBuilder',
373-
'org.bouncycastle.util.Arrays',
374-
'org.bouncycastle.util.io.Streams',
375-
'org.bouncycastle.cert.jcajce.JcaX509CertificateHolder',
376-
'org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider',
377-
'org.bouncycastle.cert.X509CertificateHolder',
378-
'org.bouncycastle.openssl.PEMKeyPair',
379-
'org.bouncycastle.openssl.PEMParser',
380-
'org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter',
381-
'org.bouncycastle.crypto.InvalidCipherTextException',
382-
'org.bouncycastle.jce.provider.BouncyCastleProvider',
286+
// Bouncycastle is an optional dependency for apache directory, cryptacular and opensaml packages. We
287+
// acknowledge them here instead of adding bouncy castle as a compileOnly dependency
288+
'org.bouncycastle.asn1.ASN1Encodable',
289+
'org.bouncycastle.asn1.ASN1InputStream',
290+
'org.bouncycastle.asn1.ASN1Integer',
291+
'org.bouncycastle.asn1.ASN1ObjectIdentifier',
292+
'org.bouncycastle.asn1.ASN1OctetString',
293+
'org.bouncycastle.asn1.ASN1Primitive',
294+
'org.bouncycastle.asn1.ASN1Sequence',
295+
'org.bouncycastle.asn1.ASN1TaggedObject',
296+
// 'org.bouncycastle.asn1.DEROctetString',
297+
'org.bouncycastle.asn1.pkcs.EncryptedPrivateKeyInfo',
298+
'org.bouncycastle.asn1.pkcs.EncryptionScheme',
299+
'org.bouncycastle.asn1.pkcs.KeyDerivationFunc',
300+
'org.bouncycastle.asn1.pkcs.PBEParameter',
301+
'org.bouncycastle.asn1.pkcs.PBES2Parameters',
302+
'org.bouncycastle.asn1.pkcs.PBKDF2Params',
303+
'org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers',
304+
'org.bouncycastle.asn1.pkcs.PrivateKeyInfo',
305+
'org.bouncycastle.asn1.x500.AttributeTypeAndValue',
306+
'org.bouncycastle.asn1.x500.RDN',
307+
'org.bouncycastle.asn1.x500.X500Name',
308+
'org.bouncycastle.asn1.x509.AccessDescription',
309+
'org.bouncycastle.asn1.x509.AlgorithmIdentifier',
310+
'org.bouncycastle.asn1.x509.AuthorityKeyIdentifier',
311+
'org.bouncycastle.asn1.x509.BasicConstraints',
312+
'org.bouncycastle.asn1.x509.DistributionPoint',
313+
'org.bouncycastle.asn1.x509.Extension',
314+
'org.bouncycastle.asn1.x509.GeneralName',
315+
'org.bouncycastle.asn1.x509.GeneralNames',
316+
'org.bouncycastle.asn1.x509.GeneralNamesBuilder',
317+
'org.bouncycastle.asn1.x509.KeyPurposeId',
318+
'org.bouncycastle.asn1.x509.KeyUsage',
319+
'org.bouncycastle.asn1.x509.PolicyInformation',
320+
'org.bouncycastle.asn1.x509.SubjectKeyIdentifier',
321+
'org.bouncycastle.asn1.x509.SubjectPublicKeyInfo',
322+
// 'org.bouncycastle.asn1.x9.DomainParameters',
323+
// 'org.bouncycastle.asn1.x9.ECNamedCurveTable',
324+
'org.bouncycastle.asn1.x9.X9ECParameters',
325+
'org.bouncycastle.cert.X509v3CertificateBuilder',
326+
'org.bouncycastle.cert.jcajce.JcaX509CertificateConverter',
327+
'org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils',
328+
'org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder',
329+
'org.bouncycastle.crypto.BlockCipher',
330+
'org.bouncycastle.crypto.BufferedBlockCipher',
331+
'org.bouncycastle.crypto.CipherParameters',
332+
'org.bouncycastle.crypto.Digest',
333+
'org.bouncycastle.crypto.PBEParametersGenerator',
334+
'org.bouncycastle.crypto.StreamCipher',
335+
'org.bouncycastle.crypto.agreement.kdf.ConcatenationKDFGenerator',
336+
// 'org.bouncycastle.crypto.ec.CustomNamedCurves',
337+
'org.bouncycastle.crypto.generators.BCrypt',
338+
'org.bouncycastle.crypto.generators.OpenSSLPBEParametersGenerator',
339+
'org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator',
340+
'org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator',
341+
'org.bouncycastle.crypto.macs.HMac',
342+
'org.bouncycastle.crypto.modes.AEADBlockCipher',
343+
'org.bouncycastle.crypto.paddings.BlockCipherPadding',
344+
'org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher',
345+
'org.bouncycastle.crypto.params.AsymmetricKeyParameter',
346+
'org.bouncycastle.crypto.params.DSAKeyParameters',
347+
'org.bouncycastle.crypto.params.DSAParameters',
348+
'org.bouncycastle.crypto.params.DSAPrivateKeyParameters',
349+
'org.bouncycastle.crypto.params.DSAPublicKeyParameters',
350+
'org.bouncycastle.crypto.params.ECDomainParameters',
351+
'org.bouncycastle.crypto.params.ECKeyParameters',
352+
'org.bouncycastle.crypto.params.ECPrivateKeyParameters',
353+
'org.bouncycastle.crypto.params.ECPublicKeyParameters',
354+
// 'org.bouncycastle.crypto.params.KDFParameters',
355+
'org.bouncycastle.crypto.params.KeyParameter',
356+
'org.bouncycastle.crypto.params.RSAKeyParameters',
357+
'org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters',
358+
'org.bouncycastle.crypto.prng.EntropySource',
359+
'org.bouncycastle.crypto.prng.SP800SecureRandom',
360+
'org.bouncycastle.crypto.prng.SP800SecureRandomBuilder',
361+
'org.bouncycastle.crypto.prng.drbg.SP80090DRBG',
362+
'org.bouncycastle.crypto.signers.DSASigner',
363+
'org.bouncycastle.crypto.signers.ECDSASigner',
364+
'org.bouncycastle.crypto.signers.RSADigestSigner',
365+
'org.bouncycastle.crypto.util.PrivateKeyFactory',
366+
'org.bouncycastle.crypto.util.PrivateKeyInfoFactory',
367+
'org.bouncycastle.crypto.util.PublicKeyFactory',
368+
'org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory',
369+
'org.bouncycastle.jcajce.provider.asymmetric.dsa.KeyPairGeneratorSpi',
370+
'org.bouncycastle.jcajce.provider.asymmetric.ec.KeyPairGeneratorSpi$EC',
371+
'org.bouncycastle.jcajce.provider.asymmetric.rsa.KeyPairGeneratorSpi',
372+
'org.bouncycastle.jcajce.provider.asymmetric.util.EC5Util',
373+
'org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil',
374+
// 'org.bouncycastle.jce.ECNamedCurveTable',
375+
// 'org.bouncycastle.jce.spec.ECNamedCurveParameterSpec',
376+
'org.bouncycastle.math.ec.ECFieldElement',
377+
'org.bouncycastle.math.ec.ECPoint',
378+
'org.bouncycastle.openssl.jcajce.JcaPEMWriter',
379+
'org.bouncycastle.operator.jcajce.JcaContentSignerBuilder',
380+
'org.bouncycastle.util.Arrays',
381+
'org.bouncycastle.util.io.Streams',
382+
'org.bouncycastle.cert.X509CertificateHolder',
383383
)
384384

385385
ignoreViolations(
@@ -402,26 +402,21 @@ tasks.named("thirdPartyAudit").configure {
402402

403403
tasks.named("thirdPartyAudit").configure {
404404
ignoreMissingClasses(
405-
'javax.xml.bind.JAXBContext',
406-
'javax.xml.bind.JAXBElement',
407-
'javax.xml.bind.JAXBException',
408-
'javax.xml.bind.Unmarshaller',
409-
'javax.xml.bind.UnmarshallerHandler',
410-
// Optional dependency of oauth2-oidc-sdk that we don't need since we do not support AES-SIV for JWE
411-
'org.cryptomator.siv.SivMode',
412-
// Optional dependency of nimbus-jose-jwt for handling Ed25519 signatures and ECDH with X25519 (RFC 8037)
413-
'com.google.crypto.tink.subtle.Ed25519Sign',
414-
'com.google.crypto.tink.subtle.Ed25519Sign$KeyPair',
415-
'com.google.crypto.tink.subtle.Ed25519Verify',
416-
'com.google.crypto.tink.subtle.X25519',
417-
'com.google.crypto.tink.subtle.XChaCha20Poly1305',
418-
'com.nimbusds.common.contenttype.ContentType',
419-
'javax.activation.ActivationDataFlavor',
420-
'javax.activation.DataContentHandler',
421-
'javax.activation.DataHandler',
422-
'javax.activation.DataSource',
423-
'javax.activation.FileDataSource',
424-
'javax.activation.FileTypeMap'
405+
'javax.xml.bind.JAXBContext',
406+
'javax.xml.bind.JAXBElement',
407+
'javax.xml.bind.JAXBException',
408+
'javax.xml.bind.Unmarshaller',
409+
'javax.xml.bind.UnmarshallerHandler',
410+
// Optional dependency of oauth2-oidc-sdk that we don't need since we do not support AES-SIV for JWE
411+
'org.cryptomator.siv.SivMode',
412+
'com.nimbusds.common.contenttype.ContentType',
413+
'com.nimbusds.common.contenttype.ContentType$Parameter',
414+
'javax.activation.ActivationDataFlavor',
415+
'javax.activation.DataContentHandler',
416+
'javax.activation.DataHandler',
417+
'javax.activation.DataSource',
418+
'javax.activation.FileDataSource',
419+
'javax.activation.FileTypeMap'
425420
)
426421
}
427422

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This build deserves an explanation. Nimbus-jose-jwt uses gson internally, which is unfriendly
2+
// to our usage of the security manager, to a degree that it makes the library extremely difficult
3+
// to work with safely. The purpose of this build is to create a version of nimbus-jose-jwt with
4+
// a couple classes replaced with wrappers which work with the security manager, the source files
5+
// in this directory.
6+
7+
// Because we want to include the original class files so that we can reference them without
8+
// modification, there are a couple intermediate steps:
9+
// nimbus-jose-jwt-modified-part1: Create a version of the JAR in which the relevant class files are moved to a different package.
10+
// This is not immediately usable as this process rewrites the rest of the JAR to "correctly" reference the new classes. So, we need to...
11+
// nimbus-jose-jwt-modified-part2: Create a JAR from the result of part 1 which contains *only* the relevant class files by removing everything else.
12+
// nimbus-jose-jwt-modified: Use the result of part 2 here, combined with the original library, so that we can use our
13+
// replacement classes which wrap the original class files.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
apply plugin: 'elasticsearch.build'
9+
apply plugin: 'com.github.johnrengelman.shadow'
10+
11+
// See the build.gradle file in the parent directory for an explanation of this unusual build
12+
13+
dependencies {
14+
implementation "com.nimbusds:nimbus-jose-jwt:9.37.3"
15+
}
16+
17+
tasks.named('shadowJar').configure {
18+
// Attempting to exclude all of the classes we *don't* move here ought to be possible per the
19+
// shadowJar docs, but actually attempting to do so results in an empty JAR. May be a bug in the shadowJar plugin.
20+
relocate 'com.nimbusds.jose.util.JSONObjectUtils', 'org.elasticsearch.nimbus.jose.util.JSONObjectUtils'
21+
relocate 'com.nimbusds.jose.util.JSONStringUtils', 'org.elasticsearch.nimbus.jose.util.JSONStringUtils'
22+
}
23+
24+
['jarHell', 'thirdPartyAudit', 'forbiddenApisMain', 'splitPackagesAudit', 'licenseHeaders'].each {
25+
tasks.named(it).configure {
26+
enabled = false
27+
}
28+
}
29+
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)