Skip to content

Commit

Permalink
Merge branch 'reauth' of https://github.com/bairdo/chewie into reauth
Browse files Browse the repository at this point in the history
  • Loading branch information
Bairdo committed Apr 2, 2019
2 parents 99c2dbb + 7f1eb93 commit c9b8ff5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
3 changes: 2 additions & 1 deletion chewie/chewie.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,12 @@ def get_state_machine(self, src_mac, port_id, message_id=-1):
self.state_machines[port_id_str] = {}
state_machine = self.state_machines[port_id_str].get(src_mac_str, None)
if not state_machine:
log_prefix = "%s.SM - port: %s, client: %s" % (self.logger.name, src_mac, port_id_str)
state_machine = FullEAPStateMachine(self.eap_output_messages,
self.radius_output_messages, src_mac,
self.timer_scheduler, self.auth_success,
self.auth_failure, self.auth_logoff,
self.logger.name)
log_prefix)
state_machine.eap_restart = True
# TODO what if port is not actually enabled, but then how did they auth?
state_machine.port_enabled = True
Expand Down
3 changes: 1 addition & 2 deletions chewie/eap_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ def __init__(self, eap_output_queue, radius_output_queue, src_mac, timer_schedul
# and self.m is the one currently in use.
# if we want to deal with each method locally.
self.m = MPassthrough() # pylint: disable=invalid-name
logname = ".SM - %s" % self.src_mac
self.logger = get_logger(log_prefix + logname)
self.logger = get_logger(log_prefix)

def is_eap_restart(self):
return self.eap_restart
Expand Down
40 changes: 40 additions & 0 deletions chewie/radius_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ class UserName(Attribute):
DESCRIPTION = "User-Name"


@register_attribute_type
class NASIPAddress(Attribute):
"""Service-Type https://tools.ietf.org/html/rfc2865#section-5.4"""
TYPE = 4
DATA_TYPE = String
DESCRIPTION = "NAS-IP-Address"


@register_attribute_type
class NASPort(Attribute):
"""Service-Type https://tools.ietf.org/html/rfc2865#section-5.5"""
Expand All @@ -91,6 +99,14 @@ class ServiceType(Attribute):
DESCRIPTION = "Service-Type"


@register_attribute_type
class FilterId(Attribute):
"""Framed-MTU https://tools.ietf.org/html/rfc2865#section-5.11"""
TYPE = 11
DATA_TYPE = Text
DESCRIPTION = "Filter-Id"


@register_attribute_type
class FramedMTU(Attribute):
"""Framed-MTU https://tools.ietf.org/html/rfc2865#section-5.12"""
Expand Down Expand Up @@ -173,6 +189,22 @@ class NASPortType(Attribute):
DESCRIPTION = "NAS-Port-Type"


@register_attribute_type
class TunnelType(Attribute):
"""NAS-Port-Type https://tools.ietf.org/html/rfc2868#section-3.1"""
TYPE = 64
DATA_TYPE = Enum
DESCRIPTION = "Tunnel-Type"


@register_attribute_type
class TunnelMediumType(Attribute):
"""NAS-Port-Type https://tools.ietf.org/html/rfc2868#section-3.2"""
TYPE = 65
DATA_TYPE = Enum
DESCRIPTION = "Tunnel-Medium-Type"


@register_attribute_type
class ConnectInfo(Attribute):
"""ConnectInfo (RADIUS Extensions) https://tools.ietf.org/html/rfc2869#section-5.11"""
Expand Down Expand Up @@ -200,3 +232,11 @@ class MessageAuthenticator(Attribute):
TYPE = 80
DATA_TYPE = String
DESCRIPTION = "Message-Authenticator"


@register_attribute_type
class TunnelPrivateGroupID(Attribute):
"""NAS-Port-Type https://tools.ietf.org/html/rfc2868#section-3.6"""
TYPE = 81
DATA_TYPE = String
DESCRIPTION = "Tunnel-Private-Group-ID"
4 changes: 3 additions & 1 deletion test/test_full_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ def setUp(self):
self.radius_output_queue = Queue()
self.timer_scheduler = FakeTimerScheduler()
self.src_mac = MacAddress.from_string("00:12:34:56:78:90")
log_prefix = "chewie.SM - port: %s, client: %s" % (self.src_mac, self.PORT_ID_MAC)

self.sm = FullEAPStateMachine(self.eap_output_queue, self.radius_output_queue, self.src_mac,
self.timer_scheduler,
self.auth_handler, self.failure_handler, self.logoff_handler,
'Chewie')
log_prefix)
# find ways to inject these - overriding consts isn't ideal
self.MAX_RETRANSMITS = 3
self.sm.MAX_RETRANS = self.MAX_RETRANSMITS
Expand Down

0 comments on commit c9b8ff5

Please sign in to comment.