Created
April 5, 2021 14:52
-
-
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)
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
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