Skip to content
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

Replace user/password in URL with HTTP header Basic authentication, to avoid credentials ending up in log files #50

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions napalm_srl/srl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Napalm driver for SR Linux.

Read https://napalm.readthedocs.io for more information.
"""
"""
import base64
import json
import logging
Expand Down Expand Up @@ -2592,11 +2592,11 @@ def _jsonrpcPost(self, json_data, timeout=None):
"Accept": "application/json",
}
proto = "https" if (self.jsonrpc_port==443 or (self.jsonrpc_port!=80 and not self.insecure)) else "http"
geturl = f"{proto}://{self.username}:{self.password}@{self.hostname}:{self.jsonrpc_port}/jsonrpc"
geturl = f"{proto}://{self.hostname}:{self.jsonrpc_port}/jsonrpc"
cert = ( self.tls_cert, self.tls_key ) if self.tls_cert and self.tls_key else None
resp = self.jsonrpc_session.post(geturl, headers=headers, json=json_data,
timeout=timeout if timeout else self.timeout,
cert=cert,
auth=(self.username, self.password), cert=cert,
verify=False if self.skip_verify else self.tls_ca)
resp.raise_for_status()
return resp.json() if resp.text else ""
Expand Down