authentik.common.saml.constants
SAML Source processor constants
1"""SAML Source processor constants""" 2 3import xmlsec 4 5NS_SAML_PROTOCOL = "urn:oasis:names:tc:SAML:2.0:protocol" 6NS_SAML_ASSERTION = "urn:oasis:names:tc:SAML:2.0:assertion" 7NS_SAML_METADATA = "urn:oasis:names:tc:SAML:2.0:metadata" 8NS_SIGNATURE = "http://www.w3.org/2000/09/xmldsig#" 9NS_ENC = "http://www.w3.org/2001/04/xmlenc#" 10 11NS_MAP = { 12 "samlp": NS_SAML_PROTOCOL, 13 "saml": NS_SAML_ASSERTION, 14 "ds": NS_SIGNATURE, 15 "md": NS_SAML_METADATA, 16 "xenc": NS_ENC, 17} 18 19SAML_NAME_ID_FORMAT_EMAIL = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" 20SAML_NAME_ID_FORMAT_PERSISTENT = "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" 21SAML_NAME_ID_FORMAT_UNSPECIFIED = "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" 22SAML_NAME_ID_FORMAT_X509 = "urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName" 23SAML_NAME_ID_FORMAT_WINDOWS = "urn:oasis:names:tc:SAML:2.0:nameid-format:WindowsDomainQualifiedName" 24SAML_NAME_ID_FORMAT_TRANSIENT = "urn:oasis:names:tc:SAML:2.0:nameid-format:transient" 25 26SAML_ATTRIBUTES_GROUP = "http://schemas.xmlsoap.org/claims/Group" 27 28SAML_BINDING_POST = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" 29SAML_BINDING_REDIRECT = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" 30 31# Bindings authentik supports. Metadata commonly advertises further bindings 32# (SOAP, HTTP-Artifact, PAOS, ...) which we can't use. 33SAML_BINDINGS_SUPPORTED = (SAML_BINDING_REDIRECT, SAML_BINDING_POST) 34 35SAML_STATUS_SUCCESS = "urn:oasis:names:tc:SAML:2.0:status:Success" 36 37DEFAULT_ISSUER = "authentik" 38 39DSA_SHA1 = "http://www.w3.org/2000/09/xmldsig#dsa-sha1" 40RSA_SHA1 = "http://www.w3.org/2000/09/xmldsig#rsa-sha1" 41# https://datatracker.ietf.org/doc/html/rfc4051#section-2.3.2 42RSA_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" 43RSA_SHA384 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384" 44RSA_SHA512 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512" 45# https://datatracker.ietf.org/doc/html/rfc4051#section-2.3.6 46ECDSA_SHA1 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1" 47ECDSA_SHA224 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224" 48ECDSA_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256" 49ECDSA_SHA384 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384" 50ECDSA_SHA512 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512" 51 52SHA1 = "http://www.w3.org/2000/09/xmldsig#sha1" 53SHA256 = "http://www.w3.org/2001/04/xmlenc#sha256" 54SHA384 = "http://www.w3.org/2001/04/xmldsig-more#sha384" 55SHA512 = "http://www.w3.org/2001/04/xmlenc#sha512" 56 57SIGN_ALGORITHM_TRANSFORM_MAP = { 58 DSA_SHA1: xmlsec.constants.TransformDsaSha1, 59 RSA_SHA1: xmlsec.constants.TransformRsaSha1, 60 RSA_SHA256: xmlsec.constants.TransformRsaSha256, 61 RSA_SHA384: xmlsec.constants.TransformRsaSha384, 62 RSA_SHA512: xmlsec.constants.TransformRsaSha512, 63 ECDSA_SHA1: xmlsec.constants.TransformEcdsaSha1, 64 ECDSA_SHA224: xmlsec.constants.TransformEcdsaSha224, 65 ECDSA_SHA256: xmlsec.constants.TransformEcdsaSha256, 66 ECDSA_SHA384: xmlsec.constants.TransformEcdsaSha384, 67 ECDSA_SHA512: xmlsec.constants.TransformEcdsaSha512, 68} 69 70DIGEST_ALGORITHM_TRANSLATION_MAP = { 71 SHA1: xmlsec.constants.TransformSha1, 72 SHA256: xmlsec.constants.TransformSha256, 73 SHA384: xmlsec.constants.TransformSha384, 74 SHA512: xmlsec.constants.TransformSha512, 75} 76 77AES128_CBC = "http://www.w3.org/2001/04/xmlenc#aes128-cbc" 78AES256_CBC = "http://www.w3.org/2001/04/xmlenc#aes256-cbc" 79AES128_GCM = "http://www.w3.org/2009/xmlenc11#aes128-gcm" 80AES256_GCM = "http://www.w3.org/2009/xmlenc11#aes256-gcm" 81RSA_OAEP_MGF1P = "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" 82 83# Algorithms advertised in SP metadata as <md:EncryptionMethod>, in order of preference 84ENCRYPTION_METHODS_ADVERTISED = ( 85 AES256_GCM, 86 AES128_GCM, 87 AES256_CBC, 88 AES128_CBC, 89 RSA_OAEP_MGF1P, 90) 91 92ENCRYPTION_ALGORITHM_TRANSLATION_MAP = { 93 AES128_CBC: (xmlsec.constants.TransformAes128Cbc, 128), 94 AES256_CBC: (xmlsec.constants.TransformAes256Cbc, 256), 95 AES128_GCM: (xmlsec.constants.TransformAes128Gcm, 128), 96 AES256_GCM: (xmlsec.constants.TransformAes256Gcm, 256), 97}
NS_SAML_PROTOCOL =
'urn:oasis:names:tc:SAML:2.0:protocol'
NS_SAML_ASSERTION =
'urn:oasis:names:tc:SAML:2.0:assertion'
NS_SAML_METADATA =
'urn:oasis:names:tc:SAML:2.0:metadata'
NS_SIGNATURE =
'http://www.w3.org/2000/09/xmldsig#'
NS_ENC =
'http://www.w3.org/2001/04/xmlenc#'
NS_MAP =
{'samlp': 'urn:oasis:names:tc:SAML:2.0:protocol', 'saml': 'urn:oasis:names:tc:SAML:2.0:assertion', 'ds': 'http://www.w3.org/2000/09/xmldsig#', 'md': 'urn:oasis:names:tc:SAML:2.0:metadata', 'xenc': 'http://www.w3.org/2001/04/xmlenc#'}
SAML_NAME_ID_FORMAT_EMAIL =
'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'
SAML_NAME_ID_FORMAT_PERSISTENT =
'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
SAML_NAME_ID_FORMAT_UNSPECIFIED =
'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified'
SAML_NAME_ID_FORMAT_X509 =
'urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName'
SAML_NAME_ID_FORMAT_WINDOWS =
'urn:oasis:names:tc:SAML:2.0:nameid-format:WindowsDomainQualifiedName'
SAML_NAME_ID_FORMAT_TRANSIENT =
'urn:oasis:names:tc:SAML:2.0:nameid-format:transient'
SAML_ATTRIBUTES_GROUP =
'http://schemas.xmlsoap.org/claims/Group'
SAML_BINDING_POST =
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'
SAML_BINDING_REDIRECT =
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'
SAML_BINDINGS_SUPPORTED =
('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST')
SAML_STATUS_SUCCESS =
'urn:oasis:names:tc:SAML:2.0:status:Success'
DEFAULT_ISSUER =
$POSTGRES_USER
DSA_SHA1 =
'http://www.w3.org/2000/09/xmldsig#dsa-sha1'
RSA_SHA1 =
'http://www.w3.org/2000/09/xmldsig#rsa-sha1'
RSA_SHA256 =
'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'
RSA_SHA384 =
'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384'
RSA_SHA512 =
'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512'
ECDSA_SHA1 =
'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1'
ECDSA_SHA224 =
'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224'
ECDSA_SHA256 =
'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256'
ECDSA_SHA384 =
'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384'
ECDSA_SHA512 =
'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512'
SHA1 =
'http://www.w3.org/2000/09/xmldsig#sha1'
SHA256 =
'http://www.w3.org/2001/04/xmlenc#sha256'
SHA384 =
'http://www.w3.org/2001/04/xmldsig-more#sha384'
SHA512 =
'http://www.w3.org/2001/04/xmlenc#sha512'
SIGN_ALGORITHM_TRANSFORM_MAP =
{'http://www.w3.org/2000/09/xmldsig#dsa-sha1': __Transform('dsa-sha1', 'http://www.w3.org/2000/09/xmldsig#dsa-sha1', 8), 'http://www.w3.org/2000/09/xmldsig#rsa-sha1': __Transform('rsa-sha1', 'http://www.w3.org/2000/09/xmldsig#rsa-sha1', 8), 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256': __Transform('rsa-sha256', 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256', 8), 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384': __Transform('rsa-sha384', 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384', 8), 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512': __Transform('rsa-sha512', 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512', 8), 'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1': __Transform('ecdsa-sha1', 'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1', 8), 'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224': __Transform('ecdsa-sha224', 'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224', 8), 'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256': __Transform('ecdsa-sha256', 'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256', 8), 'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384': __Transform('ecdsa-sha384', 'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384', 8), 'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512': __Transform('ecdsa-sha512', 'http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512', 8)}
DIGEST_ALGORITHM_TRANSLATION_MAP =
{'http://www.w3.org/2000/09/xmldsig#sha1': __Transform('sha1', 'http://www.w3.org/2000/09/xmldsig#sha1', 4), 'http://www.w3.org/2001/04/xmlenc#sha256': __Transform('sha256', 'http://www.w3.org/2001/04/xmlenc#sha256', 4), 'http://www.w3.org/2001/04/xmldsig-more#sha384': __Transform('sha384', 'http://www.w3.org/2001/04/xmldsig-more#sha384', 4), 'http://www.w3.org/2001/04/xmlenc#sha512': __Transform('sha512', 'http://www.w3.org/2001/04/xmlenc#sha512', 4)}
AES128_CBC =
'http://www.w3.org/2001/04/xmlenc#aes128-cbc'
AES256_CBC =
'http://www.w3.org/2001/04/xmlenc#aes256-cbc'
AES128_GCM =
'http://www.w3.org/2009/xmlenc11#aes128-gcm'
AES256_GCM =
'http://www.w3.org/2009/xmlenc11#aes256-gcm'
RSA_OAEP_MGF1P =
'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p'
ENCRYPTION_METHODS_ADVERTISED =
('http://www.w3.org/2009/xmlenc11#aes256-gcm', 'http://www.w3.org/2009/xmlenc11#aes128-gcm', 'http://www.w3.org/2001/04/xmlenc#aes256-cbc', 'http://www.w3.org/2001/04/xmlenc#aes128-cbc', 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p')
ENCRYPTION_ALGORITHM_TRANSLATION_MAP =
{'http://www.w3.org/2001/04/xmlenc#aes128-cbc': (__Transform('aes128-cbc', 'http://www.w3.org/2001/04/xmlenc#aes128-cbc', 16), 128), 'http://www.w3.org/2001/04/xmlenc#aes256-cbc': (__Transform('aes256-cbc', 'http://www.w3.org/2001/04/xmlenc#aes256-cbc', 16), 256), 'http://www.w3.org/2009/xmlenc11#aes128-gcm': (__Transform('aes128-gcm', 'http://www.w3.org/2009/xmlenc11#aes128-gcm', 16), 128), 'http://www.w3.org/2009/xmlenc11#aes256-gcm': (__Transform('aes256-gcm', 'http://www.w3.org/2009/xmlenc11#aes256-gcm', 16), 256)}