Utilities

class flask_saml2.utils.cached_property(func, name=None, doc=None)

A decorator that converts a function into a lazy property. The function wrapped is called the first time to retrieve the result and then that calculated result is used the next time you access the value:

class Foo(object):
    @cached_property
    def foo(self):
        # calculate something important here
        return 42

The class has to have a __dict__ in order for this property to work.

flask_saml2.utils.import_string(path)

Import a dotted Python path to a class or other module attribute. import_string('foo.bar.MyClass') will return the class MyClass from the package foo.bar.

Return type

Any

flask_saml2.utils.get_random_id()

Generate a random ID string. The random ID will start with the ‘_’ character.

Return type

str

flask_saml2.utils.utcnow()

Get the current time in UTC, as an aware datetime.datetime.

Return type

datetime

flask_saml2.utils.certificate_to_string(certificate)

Take an x509 certificate and encode it to a string suitable for adding to XML responses.

Parameters

certificate (X509) – A certificate, perhaps loaded from certificate_from_file().

Return type

str

flask_saml2.utils.certificate_from_string(certificate, format=1)

Load an X509 certificate from a string. This just strips off the header and footer text.

Parameters
Return type

X509

flask_saml2.utils.certificate_from_file(filename, format=1)

Load an X509 certificate from filename.

Parameters
Return type

X509

flask_saml2.utils.private_key_from_string(private_key, format=1)

Load a private key from a string.

Parameters
Return type

PKey

flask_saml2.utils.private_key_from_file(filename, format=1)

Load a private key from filename.

Parameters
Return type

PKey