Skip to content

Commit d4a2c53

Browse files
committed
fix: authenticate via API in a11y scanner to bypass async form rendering
1 parent 447d45e commit d4a2c53

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

.github/workflows/a11y-scan.yaml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ jobs:
115115
exit 1
116116
fi
117117
118+
- name: Authenticate via API
119+
id: auth
120+
run: |
121+
# Login via backend API and capture session cookie
122+
curl -s -c /tmp/cookies.txt \
123+
-X POST http://localhost:3080/api/auth/login \
124+
-H 'Content-Type: application/json' \
125+
-d '{"email":"${{ env.AUTH_INITIAL_ADMIN_USERNAME }}","password":"${{ env.AUTH_INITIAL_ADMIN_PASSWORD }}"}'
126+
127+
# Convert Netscape cookie jar to Playwright auth_context JSON
128+
AUTH_CONTEXT=$(awk '!/^#/ && NF {
129+
printf "{\"name\":\"%s\",\"value\":\"%s\",\"domain\":\"%s\",\"path\":\"%s\",\"secure\":%s,\"httpOnly\":%s}\n",
130+
$6, $7, $1, $3, ($4=="TRUE"?"true":"false"), ($2=="TRUE"?"true":"false")
131+
}' /tmp/cookies.txt | jq -sc '{
132+
username: "${{ env.AUTH_INITIAL_ADMIN_USERNAME }}",
133+
password: "${{ env.AUTH_INITIAL_ADMIN_PASSWORD }}",
134+
cookies: .,
135+
localStorage: {}
136+
}')
137+
138+
echo "auth_context=$AUTH_CONTEXT" >> "$GITHUB_OUTPUT"
139+
118140
- uses: github/accessibility-scanner@v2
119141
with:
120142
urls: |
@@ -129,12 +151,13 @@ jobs:
129151
repository: ${{ github.repository }}
130152
token: ${{ secrets.GH_TOKEN_A11Y }}
131153
cache_key: cached_results-c4-local.json
132-
login_url: http://localhost:3080/login # Optional: URL of the login page if authentication is required
133-
username: ${{ env.AUTH_INITIAL_ADMIN_USERNAME }} # Optional: Username for authentication
134-
password: ${{ env.AUTH_INITIAL_ADMIN_PASSWORD }} # Optional: Password for authentication (use secrets!)
135-
open_grouped_issues: true # Optional: Set to true to open an issue grouping individual issues per violation
136-
skip_copilot_assignment: true # Optional: Set to true to skip assigning issues to GitHub Copilot (or if you don't have GitHub Copilot)
137-
include_screenshots: true # Optional: Set to true to capture screenshots and include links to them in filed issues
154+
auth_context: ${{ steps.auth.outputs.auth_context }}
155+
open_grouped_issues: true
156+
skip_copilot_assignment: true
157+
include_screenshots: true
158+
# login_url: # Optional: URL of the login page if authentication is required
159+
# username: # Optional: Username for authentication
160+
# password: ${{ secrets.PASSWORD }} # Optional: Password for authentication (use secrets!)
138161
# auth_context: # Optional: Stringified JSON object for complex authentication
139162
# reduced_motion: no-preference # Optional: Playwright reduced motion configuration option
140163
# color_scheme: light # Optional: Playwright color scheme configuration option

0 commit comments

Comments
 (0)