Beispiel #1
0
def get_public_cert_file(
        expiration_in_seconds=certificates.DEFAULT_EXPIRATION):
    key_pair = certificates.create_key_pair()
    cert = certificates.create_self_signed_cert(key_pair,
                                                expiration_in_seconds)
    cert_bytes = certificates.crypto.dump_certificate(
        certificates.crypto.FILETYPE_PEM, cert)
    return SimpleUploadedFile(
        "certificate.cer",
        cert_bytes,
        content_type="application/x-x509-ca-cert",
    )
Beispiel #2
0
    def __init__(self):
        """
        To increase the security with SAML transactions, we will provide the IdP
        with our public key for an x509 certificate unique to our interactions with
        a particular IdP. This certificate will be regenerated automatically by
        a periodic task every year.
        """
        key_pair = certificates.create_key_pair()
        cert = certificates.create_self_signed_cert(key_pair)

        self.public_key = certificates.get_public_key(cert)
        self.private_key = certificates.get_private_key(key_pair)
        self.date_expires = certificates.get_expiration_date(cert)
Beispiel #3
0
def create_idp(slug, account, include_certs=False):
    idp = IdentityProvider(
        name=f"Azure AD for {account.name}",
        slug=slug,
        owner=account,
    )
    idp.save()
    if include_certs:
        idp.create_service_provider_certificate()
        idp.entity_id = "https://testidp.com/saml2/entity_id"
        idp.login_url = "https://testidp.com/saml2/login"
        idp.logout_url = "https://testidp.com/saml2/logout"
        key_pair = certificates.create_key_pair()
        cert = certificates.create_self_signed_cert(key_pair)
        idp.idp_cert_public = certificates.get_public_key(cert)
        idp.date_idp_cert_expiration = certificates.get_expiration_date(cert)
        idp.save()
    return idp
Beispiel #4
0
def create_idp(account=None, include_certs=False):
    if not account:
        account = get_billing_account_for_idp()
    idp_slug = data_gen.arbitrary_unique_name()[:20]
    idp = IdentityProvider(name=f"Azure AD for {account.name}",
                           slug=idp_slug,
                           owner=account)
    idp.save()
    if include_certs:
        idp.create_service_provider_certificate()
        idp.entity_id = "https://testidp.com/saml2/entity_id"
        idp.login_url = "https://testidp.com/saml2/login"
        idp.logout_url = "https://testidp.com/saml2/logout"
        key_pair = certificates.create_key_pair()
        cert = certificates.create_self_signed_cert(key_pair)
        idp.idp_cert_public = certificates.get_public_key(cert)
        idp.date_idp_cert_expiration = certificates.get_expiration_date(cert)
        idp.save()
    return idp