Skip to content

Add ONVIF authentication with UsernameToken support#2231

Open
ssttevee wants to merge 1 commit into
AlexxIT:masterfrom
ssttevee:onvif-auth
Open

Add ONVIF authentication with UsernameToken support#2231
ssttevee wants to merge 1 commit into
AlexxIT:masterfrom
ssttevee:onvif-auth

Conversation

@ssttevee
Copy link
Copy Markdown

AI DISCLOSURE: This feature was so straightforward that I wanted to try using codex and as far as I can tell, it did quite well. I did review the changes before opening this PR and nothing really bad stuck out to me (some global vars but seems valid tbh).

Summary

  • stop applying api.username / api.password HTTP Basic auth to /onvif/* so ONVIF SOAP requests can reach the ONVIF handler
  • add dedicated onvif.username / onvif.password config and validate WS-Security UsernameToken credentials inside the ONVIF service
  • keep GetSystemDateAndTime unauthenticated and return an ONVIF-style ter:NotAuthorized SOAP fault when ONVIF auth fails

Reasoning

External ONVIF clients such as ODM, NVRs, and VMS platforms typically authenticate with WS-Security UsernameToken in the SOAP header, not HTTP Basic auth. When go2rtc applies API Basic auth to the shared HTTP listener, those clients fail before the SOAP request can be processed.

This change separates the two auth layers:

  • Web API remains protected by api.username / api.password
  • ONVIF can be protected independently with WS-Security credentials
  • GetSystemDateAndTime stays open because ONVIF clients commonly use it first to calculate clock skew before generating a valid password digest

Sources

Testing

  • go test ./pkg/onvif ./internal/api ./internal/onvif

closes #2148

- Allow independent ONVIF auth via config
- Skip API auth for /onvif/* paths
- Require WS-Security UsernameToken for ONVIF SOAP requests
- Add tests for ONVIF and API authentication logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Separate ONVIF server authentication from API HTTP Basic Auth

1 participant