Skip to content

Commit 6a54972

Browse files
committed
fix: Fixing the memory leak introduced in the DPoP flow
1 parent 03f0311 commit 6a54972

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

auth0/src/main/java/com/auth0/android/dpop/DPoP.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public data class HeaderData(val authorizationHeader: String, val dpopProof: Str
2222
* Class for securing requests with DPoP (Demonstrating Proof of Possession) as described in
2323
* [RFC 9449](https://datatracker.ietf.org/doc/html/rfc9449).
2424
*/
25-
public class DPoP(private val context: Context) {
25+
public class DPoP(context: Context) {
26+
27+
private val applicationContext: Context = context.applicationContext
2628

2729
/**
2830
* Determines whether a DPoP proof should be generated for the given URL and parameters. The proof should
@@ -79,7 +81,7 @@ public class DPoP(private val context: Context) {
7981
*/
8082
@Throws(DPoPException::class)
8183
internal fun generateKeyPair() {
82-
DPoPUtil.generateKeyPair(context)
84+
DPoPUtil.generateKeyPair(applicationContext)
8385
}
8486

8587
/**

auth0/src/test/java/com/auth0/android/authentication/AuthenticationAPIClientTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public class AuthenticationAPIClientTest {
7676
mockAPI = AuthenticationAPIMockServer()
7777
mockKeyStore = mock()
7878
mockContext = mock()
79+
whenever(mockContext.applicationContext).thenReturn(mockContext)
7980
val auth0 = auth0
8081
client = AuthenticationAPIClient(auth0)
8182
gson = GsonBuilder().serializeNulls().create()

auth0/src/test/java/com/auth0/android/dpop/DPoPTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class DPoPTest {
4747
mockResponse = mock()
4848
mockKeyStore = mock()
4949
mockResponseBody = mock()
50+
51+
whenever(mockContext.applicationContext).thenReturn(mockContext)
5052
dPoP = DPoP(mockContext)
5153

5254
DPoP._auth0Nonce = null

auth0/src/test/java/com/auth0/android/provider/WebAuthProviderTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public class WebAuthProviderTest {
9595

9696
mockKeyStore = mock()
9797
mockContext = mock()
98+
Mockito.`when`(mockContext.applicationContext).thenReturn(mockContext)
9899

99100
DPoPUtil.keyStore = mockKeyStore
100101

0 commit comments

Comments
 (0)