-
-
Notifications
You must be signed in to change notification settings - Fork 719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client Script Based Auth (Ajax Spider) #6112
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
7e2f645
to
4323379
Compare
4323379
to
a1cbcf7
Compare
I believe this is ready for review. There is an outstanding issue where one of the browser windows may not close. I'm investigating. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor comment. I'm sure theres a load of dup code from core here so at some point it would be really good to rationalise it. But maybe not today ;)
...main/java/org/zaproxy/addon/authhelper/client/ClientScriptBasedAuthenticationMethodType.java
Outdated
Show resolved
Hide resolved
a1cbcf7
to
d842ed9
Compare
...thhelper/src/main/java/org/zaproxy/addon/authhelper/client/ClientScriptBasedAuthHandler.java
Outdated
Show resolved
Hide resolved
...main/java/org/zaproxy/addon/authhelper/client/ClientScriptBasedAuthenticationMethodType.java
Outdated
Show resolved
Hide resolved
...main/java/org/zaproxy/addon/authhelper/client/ClientScriptBasedAuthenticationMethodType.java
Outdated
Show resolved
Hide resolved
addOns/automation/src/main/java/org/zaproxy/addon/automation/AuthenticationData.java
Outdated
Show resolved
Hide resolved
addOns/automation/src/main/java/org/zaproxy/addon/automation/AuthenticationData.java
Outdated
Show resolved
Hide resolved
addOns/automation/src/main/java/org/zaproxy/addon/automation/AuthenticationData.java
Outdated
Show resolved
Hide resolved
addOns/automation/src/main/java/org/zaproxy/addon/automation/AuthenticationData.java
Outdated
Show resolved
Hide resolved
addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/dialogs/ZestRecordScriptDialog.java
Outdated
Show resolved
Hide resolved
Thanks for reviewing, I figured things would need to move around and that dependencies might be wrong, some of that I blindly trusted and some of it I just wasn't confident about the changes myself. |
f841f32
to
d02f036
Compare
At d02f036 it's failing to load the script when running via automation:
Edit: 13c993a should be the same. |
8d1964e
to
13c993a
Compare
Here's the plan and script to re-create, you'll have to edit the script path to be correct for your system. Zest Test Script{
"about": "This is a Zest script. For more details about Zest visit https://github.com/zaproxy/zest/",
"zestVersion": "0.8",
"title": "RecordedTestAuth",
"description": "",
"prefix": "",
"type": "StandAlone",
"parameters": {
"tokenStart": "{{",
"tokenEnd": "}}",
"tokens": {},
"elementType": "ZestVariables"
},
"statements": [
{
"windowHandle": "windowHandle1",
"browserType": "firefox",
"url": "http://localhost:9091/auth/simple-json-cookie/",
"capabilities": "",
"headless": false,
"profilePath": "",
"index": 1,
"enabled": true,
"elementType": "ZestClientLaunch"
},
{
"windowHandle": "windowHandle1",
"type": "id",
"element": "user",
"index": 2,
"enabled": true,
"elementType": "ZestClientElementClick"
},
{
"value": "[email protected]",
"windowHandle": "windowHandle1",
"type": "id",
"element": "user",
"index": 3,
"enabled": true,
"elementType": "ZestClientElementSendKeys"
},
{
"value": "password123",
"windowHandle": "windowHandle1",
"type": "id",
"element": "password",
"index": 4,
"enabled": true,
"elementType": "ZestClientElementSendKeys"
},
{
"windowHandle": "windowHandle1",
"type": "id",
"element": "login",
"index": 5,
"enabled": true,
"elementType": "ZestClientElementClick"
}
],
"authentication": [],
"index": 0,
"enabled": true,
"elementType": "ZestScript"
}
AF Test Planenv:
contexts:
- name: AjaxSpiderAuthTest
urls:
- http://localhost:9091/auth/simple-json-cookie
includePaths:
- http://localhost:9091/auth/simple-json-cookie.*
authentication:
method: client
parameters:
script: /some/path/RecordedTestAuth.zst
scriptEngine: Mozilla Zest
verification:
method: poll
loggedInRegex: \Q 200 OK\E
loggedOutRegex: \Q 403 Forbidden\E
pollFrequency: 60
pollUnits: seconds
pollUrl: http://localhost:9091/auth/simple-json-cookie/user
pollPostData: ""
sessionManagement:
method: headers
parameters:
Cookie: "sid={%cookie:sid%}; _random=blahblah"
technology: {}
structure: {}
users:
- name: test
credentials:
Username: [email protected]
Password: password123
parameters: {}
jobs:
- type: spiderAjax
parameters:
context: AjaxSpiderAuthTest
user: test
browserId: firefox
tests:
- name: At least 30 URLs found
type: stats
onFail: INFO
statistic: spiderAjax.urls.added
operator: '>='
value: 30
|
I didn't double check but that seems to be because of #6112 (comment) since the add-on itself doesn't have access to Zest. Edit: further edits, I think the first version was/is correct as it's trying to instantiate the other class, which is the one that needs access to but we'll see. |
addOns/automation/src/main/java/org/zaproxy/addon/automation/AuthenticationData.java
Outdated
Show resolved
Hide resolved
13c993a
to
3b16025
Compare
Should be functional now, with the build file changes. |
756075e
to
da7a849
Compare
Should also update the AF docs, e.g. |
4db2bd6
to
83268b4
Compare
Added help content. |
83268b4
to
63320f0
Compare
Now with updated Auth Helper help too 😀 |
1fb0025
to
451f52b
Compare
myVarTwo: ${myVarOne}.VarTwo # Can refer other vars | ||
parameters: | ||
failOnError: true # If set exit on an error | ||
failOnError: true # If set exit on an error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes these white spaces changes are unrelated but it looked horrible, could we just go with it 😀
451f52b
to
bcd8cc6
Compare
...lper/src/main/java/org/zaproxy/addon/authhelper/spiderajax/ClientScriptBasedAuthHandler.java
Outdated
Show resolved
Hide resolved
...lper/src/main/java/org/zaproxy/addon/authhelper/spiderajax/ClientScriptBasedAuthHandler.java
Outdated
Show resolved
Hide resolved
bcd8cc6
to
04e7142
Compare
Tweaked |
addOns/automation/src/main/java/org/zaproxy/addon/automation/AuthenticationData.java
Outdated
Show resolved
Hide resolved
...n/src/main/javahelp/org/zaproxy/addon/automation/resources/help/contents/authentication.html
Outdated
Show resolved
Hide resolved
04e7142
to
63e56fc
Compare
Got those. |
...er/src/main/javahelp/org/zaproxy/addon/authhelper/resources/help/contents/client-script.html
Outdated
Show resolved
Hide resolved
...er/src/main/javahelp/org/zaproxy/addon/authhelper/resources/help/contents/client-script.html
Outdated
Show resolved
Hide resolved
addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/ZestAuthenticationRunner.java
Outdated
Show resolved
Hide resolved
addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/ZestAuthenticationRunner.java
Outdated
Show resolved
Hide resolved
...lper/src/main/java/org/zaproxy/addon/authhelper/spiderajax/ClientScriptBasedAuthHandler.java
Outdated
Show resolved
Hide resolved
...lper/src/main/java/org/zaproxy/addon/authhelper/spiderajax/ClientScriptBasedAuthHandler.java
Outdated
Show resolved
Hide resolved
63e56fc
to
476a83e
Compare
Got all those now too 🤞 |
476a83e
to
8cdfd52
Compare
Tweaked again |
Signed-off-by: kingthorin <[email protected]>
8cdfd52
to
d17875a
Compare
Thank you! |
Yay 🥳 |
Overview
Allow the Ajax Spider to use Client Side scripts to authenticate, when used in conjunction with the Auth Helper add-on.
findSessionTokenSource
inAuthUtils
.ClientScriptBasedAuthenticationMethodType
.ExtensionAuthhelperClient
updated to facilitate the new functionality.intertnal.ZestAuthRunner
which will also be used by the Client Spider in the future. This ensures that browsers are launched as expected and auth handled before other actions.ClientScriptBasedAuthHandler
handler for the new auth method type, responsible for enabling/disabling auth methods for Users, and providing the necessary BrowserHook.ExtensionAuthhelperAjax
updated to 'hook' and use the new auth method.AuthenticationData
.ZestAuthenticationRunner
to facilitate the new functionality.Related Issues
n/a
Checklist
./gradlew spotlessApply
for code formatting