Skip to content

Support enclosing the IPv6 address in brackets #627

@William-Francis

Description

@William-Francis

Shibboleth provider sends IPv6 address in brackets, like:

 <saml2:SubjectConfirmationData Address="[2001:8003:5555:9999:555a:5555:c77:d5c5]" InResponseTo="xxx" NotOnOrAfter="2019-07-02T12:12:12.966Z" Recipient="xxx"/>

The standard they are using is defined here: https://tools.ietf.org/html/rfc4038#section-5.1
in short:
"The IP address parsers should support enclosing the IPv6 address in brackets, even when the address is not used in conjunction with a port number."

Code Version

Master:
https://github.com/IdentityPython/pysaml2/blob/master/src/saml2/saml.py#L982

Expected Behavior

Check if the address is in brackets, and run the valid_ipv6() function on the item inside the list, then pass.

Current Behavior

raise ShouldValueError("Not an IPv4 or IPv6 address")

Possible Solution

Maybe not the most optimal, but should work.
It would also be possible to extract the item from the list before assigning self.address in the constructor function.

    def verify(self):
        if self.address:
            # dotted-decimal IPv4 or RFC3513 IPv6 address
            if valid_ipv4(self.address) or valid_ipv6(self.address):
                pass
            elif (isinstance(self.address, list) and self.address[0] and valid_ipv6(self.address[0])):
                pass
            else:
                raise ShouldValueError("Not an IPv4 or IPv6 address")
        elif self.dns_name:
            valid_domain_name(self.dns_name)
        return SubjectLocalityType_.verify(self)

Steps to Reproduce

<saml2:SubjectConfirmationData Address="[2001:8003:5555:9999:555a:5555:c77:d5c5]" InResponseTo="xxx" NotOnOrAfter="2019-07-02T12:12:12.966Z" Recipient="xxx"/>
Send through address with IPv6 in brackets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions