-
Notifications
You must be signed in to change notification settings - Fork 103
Using Web Credentials
Gavin Schneider edited this page Oct 23, 2017
·
1 revision
Refer to the Ruby docs for WebCredentials:
HTTP Header Auth: Class: Nexpose::WebCredentials::Headers
HTML Form Login: Class: Nexpose::WebCredentials::HTMLForms
Example of setting up HTTP Header Auth with a single header:
# Name of credential, base URL, failed login regex
webcred = Nexpose::WebCredentials::Headers.new('TESTHeader', 'https://localhost/', '.*Login failed.*')
header = Nexpose::WebCredentials::Header.new('headerName', 'headerValue')
webcred.add_header(header)
site.web_credentials << webcred
site.save(nsc)
Example of setting up HTML Form Login:
# Name of credential, base URL, login URL, failed login regex
htmlforms = Nexpose::WebCredentials::HTMLForms.new('TESTForm', 'https://localhost/', 'https://localhost/login.html', '.*Login failed.*')
# Name of form, form action, action method, content type
htmlForm = Nexpose::WebCredentials::HTMLForm.new('login', 'https://localhost/login.html', 'post', 'application/json')
# name of form field, field value, type of form field, dynamic content?, is a checkbox or radio button?
htmlForm.add_field(Nexpose::WebCredentials::Field.new('username_field', 'my_username', 'text', false, false))
htmlForm.add_field(Nexpose::WebCredentials::Field.new('password_field', 'my_password', 'password', false, false))
htmlForm.add_field(Nexpose::WebCredentials::Field.new('login', 'Log on', 'button', true, false))
htmlforms.add_html_form(htmlForm)
site.web_credentials << htmlforms
site.save(nsc)
Project Home 🔹 Release Notes 🔹 Wiki 🔹 Issues 🔹 Pull Requests