diff --git a/source/includes/auth.md b/source/includes/auth.md index 00d26c7..d977b7b 100755 --- a/source/includes/auth.md +++ b/source/includes/auth.md @@ -653,3 +653,256 @@ with the Bodgeit application. Use the [includeInContext](#contextactionincludein and use the [setAuthenticationMethod](#authenticationactionsetauthenticationmethod) to setup the authentication method and the configuration parameters. Finally use the users API to create the admin user. Refer the script in the right column on how to use the above APIs. + +## JSON Based Authentication + +```python + +#!/usr/bin/env python +import urllib.parse +from zapv2 import ZAPv2 + +context_id = 1 +apiKey = 'changeMe' +context_name = 'Default Context' +target_url = 'http://localhost:3000' + +# By default ZAP API client will connect to port 8080 +zap = ZAPv2(apikey=apiKey) + +# Use the line below if ZAP is not listening on port 8080, for example, if listening on port 8090 +# zap = ZAPv2(apikey=apiKey, proxies={'http': 'http://127.0.0.1:8090', 'https': 'http://127.0.0.1:8090'}) + + +def set_include_in_context(): + include_url = 'http://localhost:3000.*' + zap.context.include_in_context(context_name, include_url) + print('Configured include and exclude regex(s) in context') + + +def set_logged_in_indicator(): + logged_in_regex = '\QLogout\E' + logged_out_regex = '(?:Location: [./]*login\.php)|(?:\Q