Skip to content

Commit

Permalink
add kerberos delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
ltamaster committed Sep 17, 2020
1 parent 8fc3e7f commit 143958f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
9 changes: 8 additions & 1 deletion contents/winrm-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@

krb5config = None
kinit = "kinit"
krbdelegation = False

if args.hostname:
hostname = args.hostname
Expand Down Expand Up @@ -182,6 +183,11 @@
if "RD_CONFIG_KINIT" in os.environ:
kinit = os.getenv("RD_CONFIG_KINIT")

if "RD_CONFIG_KRBDELEGATION" in os.environ:
if os.getenv("RD_CONFIG_KRBDELEGATION") == "true":
krbdelegation = True
else:
krbdelegation = False

endpoint=transport+'://'+hostname+':'+port

Expand All @@ -194,7 +200,7 @@
log.debug("diabletls12:" + str(diabletls12))
log.debug("krb5config:" + krb5config)
log.debug("kinit command:" + kinit)

log.debug("kerberos delegation:" + str(krbdelegation))

if(certpath):
log.debug("certpath:" + certpath)
Expand Down Expand Up @@ -240,6 +246,7 @@
if authentication == "kerberos":
k5bConfig = kerberosauth.KerberosAuth(krb5config=krb5config, log=log, kinit_command=kinit,username=username, password=password)
k5bConfig.get_ticket()
arguments["kerberos_delegation"] = krbdelegation

session = winrm.Session(target=endpoint,
auth=(username, password),
Expand Down
13 changes: 9 additions & 4 deletions contents/winrm-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def filter(self, record):
certpath = None
krb5config = None
kinit = None
krbdelegation = False
forceTicket = False
readtimeout = None
operationtimeout = None
Expand Down Expand Up @@ -190,6 +191,12 @@ def filter(self, record):
if "RD_CONFIG_KINIT" in os.environ:
kinit = os.getenv("RD_CONFIG_KINIT")

if "RD_CONFIG_KRBDELEGATION" in os.environ:
if os.getenv("RD_CONFIG_KRBDELEGATION") == "true":
krbdelegation = True
else:
krbdelegation = False

log.debug("------------------------------------------")
log.debug("endpoint:" + endpoint)
log.debug("authentication:" + authentication)
Expand All @@ -198,14 +205,11 @@ def filter(self, record):
log.debug("diabletls12:" + str(diabletls12))
log.debug("krb5config:" + krb5config)
log.debug("kinit command:" + kinit)
log.debug("kerberos delegation:" + str(krbdelegation))
log.debug("shell:" + shell)
log.debug("readtimeout:" + str(readtimeout))
log.debug("operationtimeout:" + str(operationtimeout))
log.debug("exit Behaviour:" + exitBehaviour)




log.debug("------------------------------------------")

if not URLLIB_INSTALLED:
Expand Down Expand Up @@ -253,6 +257,7 @@ def filter(self, record):
if authentication == "kerberos":
k5bConfig = kerberosauth.KerberosAuth(krb5config=krb5config, log=log, kinit_command=kinit,username=username, password=password)
k5bConfig.get_ticket()
arguments["kerberos_delegation"] = krbdelegation

session = winrm.Session(target=endpoint,
auth=(username, password),
Expand Down
9 changes: 8 additions & 1 deletion contents/winrm-filecopier.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def winrm_upload(self,
diabletls12 = False
kinit = None
krb5config = None
krbdelegation = False
forceTicket = False

if "RD_CONFIG_AUTHTYPE" in os.environ:
Expand Down Expand Up @@ -298,6 +299,12 @@ def winrm_upload(self,
if "RD_CONFIG_KINIT" in os.environ:
kinit = os.getenv("RD_CONFIG_KINIT")

if "RD_CONFIG_KRBDELEGATION" in os.environ:
if os.getenv("RD_CONFIG_KRBDELEGATION") == "true":
krbdelegation = True
else:
krbdelegation = False

endpoint = transport+'://'+args.hostname+':'+port

arguments = {}
Expand Down Expand Up @@ -340,7 +347,7 @@ def winrm_upload(self,
if authentication == "kerberos":
k5bConfig = kerberosauth.KerberosAuth(krb5config=krb5config, log=log, kinit_command=kinit,username=username, password=password)
k5bConfig.get_ticket()

arguments["kerberos_delegation"] = krbdelegation

session = winrm.Session(target=endpoint,
auth=(username, password),
Expand Down
24 changes: 24 additions & 0 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ providers:
required: false
renderingOptions:
groupName: Kerberos
- name: krbdelegation
title: Kerberos Delegations
description: "Kerberos Delegation: if True, TGT is sent to target server to allow multiple hops"
type: Boolean
default: "false"
required: false
renderingOptions:
groupName: Kerberos
- name: WinRMcpPython
title: WinRM Python File Copier
description: Copying files to remote Windows computer
Expand Down Expand Up @@ -283,6 +291,14 @@ providers:
required: false
renderingOptions:
groupName: Kerberos
- name: krbdelegation
title: Kerberos Delegations
description: "Kerberos Delegation: if True, TGT is sent to target server to allow multiple hops"
type: Boolean
default: "false"
required: false
renderingOptions:
groupName: Kerberos
- name: WinRMCheck
title: WinRM Check Step
description: Check the connection with a remote node using winrm-python
Expand Down Expand Up @@ -377,4 +393,12 @@ providers:
required: false
renderingOptions:
groupName: Kerberos
- name: krbdelegation
title: Kerberos Delegations
description: "Kerberos Delegation: if True, TGT is sent to target server to allow multiple hops"
type: Boolean
default: "false"
required: false
renderingOptions:
groupName: Kerberos

0 comments on commit 143958f

Please sign in to comment.