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
/** | |
* Intercept the given request chain to add the Approov token to an 'Approov-Token' header. | |
* | |
* @param chain the request chain to modify | |
* @return the modified response, authenticated by Approov | |
*/ | |
override fun intercept(chain: Interceptor.Chain): Response { | |
val originalRequest = chain.request() | |
val approovToken = ApproovAttestation.shared().fetchApproovTokenAndWait(originalRequest.url().toString()).token |
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
OkHttpClient.Builder() | |
.addInterceptor(ApproovRequestInterceptor()) | |
.build() |
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
// Verify and decode the Approov token and respond with 403 if the JWT | |
// could not be decoded, has expired, or has an invalid signature | |
const checkApproovTokenJWT = jwt({ | |
secret: new Buffer(config.approovTokenSecret, 'base64'), | |
getToken: function fromApproovTokenHeader(req) { | |
// Retrieve the Approov token used to authenticate the mobile app from the request header | |
var approovToken = req.get('Approov-Token') | |
if (!approovToken) { | |
console.log('\tApproov token not specified or in the wrong format') | |
} |
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
OkHttpClient.Builder() | |
.hostnameVerifier(ApproovHostnameVerifier(OkHttpClient().hostnameVerifier())) | |
.build() |
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
OkHttpClient.Builder() | |
.hostnameVerifier(ApproovHostnameVerifier(OkHttpClient().hostnameVerifier())) | |
.build() |
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
// The current demo stage | |
config.currentDemoStage = DEMO_STAGE.APPROOV_APP_AUTH_PROTECTION | |
// The Approov token secret | |
config.approovTokenSecret = 'PUT-YOUR-APPROOV-TOKEN-SECRET-HERE' |
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
/** The current demo stage */ | |
val currentDemoStage = DemoStage.APPROOV_APP_AUTH_PROTECTION |
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
// The current demo stage | |
var currentDemoStage = DEMO_STAGE.HMAC_DYNAMIC_SECRET_PROTECTION |
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
// The current demo stage | |
var currentDemoStage = DEMO_STAGE.HMAC_STATIC_SECRET_PROTECTION |
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
val secret = HMAC_SECRET | |
var keySpec: SecretKeySpec | |
... | |
... | |
val obfuscatedSecretData = Base64.decode(secret, Base64.DEFAULT) | |
val shipFastAPIKeyData = loadShipFastAPIKey(context).toByteArray(Charsets.UTF_8) | |
for (i in 0 until minOf(obfuscatedSecretData.size, shipFastAPIKeyData.size)) { | |
obfuscatedSecretData[i] = (obfuscatedSecretData[i].toInt() xor shipFastAPIKeyData[i].toInt()).toByte() | |
} | |
val obfuscatedSecret = Base64.encode(obfuscatedSecretData, Base64.DEFAULT) |
OlderNewer