Skip to content

Instantly share code, notes, and snippets.

@Momotoculteur
Created April 5, 2021 14:52
Show Gist options
  • Save Momotoculteur/0c8ee8a6fcba4e885bcd21badb1f98fb to your computer and use it in GitHub Desktop.
Save Momotoculteur/0c8ee8a6fcba4e885bcd21badb1f98fb to your computer and use it in GitHub Desktop.
Tests dynamiques de sécurité (DAST) sous OWASP Zap avec authentification via JWT/bearer token (OpenID Connect/OAuth & Kong)
import time
def sendingRequest(msg, initiator, helper):
accessToken = GlobalVariables.getGlobalCustomVar(ACCESS_TOKEN)
# Token KO ou expiré
if accessToken is None or tokenHasExpired():
login()
#Token OK
setTokenInRequest(msg)
def tokenHasExpired(accessToken):
accessTokenCreation = GlobalVariables.getGlobalCustomVar(ACCESS_TOKEN_CREATION);
currentTime = time.time();
difference = currentTime - accessTokenCreation;
accessTokenExpiryInSeconds = GlobalVariables.getGlobalCustomVar(ACCESS_TOKEN_EXPIRY);
if difference > accessTokenExpiryInSeconds:
print "token expiré"
return True;
else:
print "token OK"
return False;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment