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

RFE - certsrv Negotiate authentication #24

Open
smanross opened this issue Sep 30, 2024 · 0 comments
Open

RFE - certsrv Negotiate authentication #24

smanross opened this issue Sep 30, 2024 · 0 comments

Comments

@smanross
Copy link

Along the same lines as the last suggestion. I've currently overridden _set_credentials to add support for negotiate authentication in order to use the currently logged in credentials for authentication instead of having to pass them in.

This requires requests-negotiate-sspi
https://github.com/brandond/requests-negotiate-sspi

** kudos to this author for additional the drop-in module for the requests module

from certsrv import Certsrv

certificate_server = Certsrv("certserver.whatever.com", auth_method="negotiate")
pem_data = certificate_server.get_cert(pem_csr, certificate_template_name)

def _set_credentials(self, username, password):
    if (not password or not username) and auth_method != "negotiate":
        raise Exception("You can't not send a user/password on any auth method other than negotiate")
    if self.auth_method == "ntlm":
        from requests_ntlm import HttpNtlmAuth

        self.session.auth = HttpNtlmAuth(username, password)
    elif self.auth_method == "cert":
        self.session.cert = (username, password)
    elif self.auth_method == "negotiate":
        from requests_negotiate_sspi import HttpNegotiateAuth
        self.session.auth = HttpNegotiateAuth()
    else:
        self.session.auth = (username, password)

Certsrv._set_credentials = _set_credentials

Thanks,
Steven

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

No branches or pull requests

1 participant