Пример #1
0
def initialize():
    auth_url = 'https://sp-test.cloudwatt.test:5000/v3'
    identity_provider = 'testIdP'
    identity_provider_url = 'https://idp-test.cloudwatt.test/idp/profile/SAML2/SOAP/ECP'
    username = '******'
    password = '******'

    my_session = kc_session.Session(session=requests.session(), verify=False)
    print(my_session)
    unscoped_plugin = saml2.Saml2UnscopedToken(auth_url, identity_provider,
                                               identity_provider_url, username,
                                               password)
    print(unscoped_plugin)

    unscoped_token = unscoped_plugin.get_auth_ref(my_session)
    print(json.dumps(unscoped_token, indent=4, separators=(',', ': ')))
Пример #2
0
    def setUp(self):
        super(AuthenticateviaSAML2Tests, self).setUp()

        self.deprecations.expect_deprecations()

        self.conf_fixture = self.useFixture(config.Config())
        conf.register_conf_options(self.conf_fixture.conf, group=self.GROUP)

        self.session = session.Session()

        self.ECP_SP_EMPTY_REQUEST_HEADERS = {
            'Accept':
            'text/html; application/vnd.paos+xml',
            'PAOS': ('ver="urn:liberty:paos:2003-08";'
                     '"urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp"')
        }

        self.ECP_SP_SAML2_REQUEST_HEADERS = {
            'Content-Type': 'application/vnd.paos+xml'
        }

        self.ECP_SAML2_NAMESPACES = {
            'ecp': 'urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp',
            'S': 'http://schemas.xmlsoap.org/soap/envelope/',
            'paos': 'urn:liberty:paos:2003-08'
        }
        self.ECP_RELAY_STATE = '//ecp:RelayState'
        self.ECP_SERVICE_PROVIDER_CONSUMER_URL = ('/S:Envelope/S:Header/paos:'
                                                  'Request/'
                                                  '@responseConsumerURL')
        self.ECP_IDP_CONSUMER_URL = ('/S:Envelope/S:Header/ecp:Response/'
                                     '@AssertionConsumerServiceURL')
        self.IDENTITY_PROVIDER = 'testidp'
        self.IDENTITY_PROVIDER_URL = 'http://local.url'
        self.PROTOCOL = 'saml2'
        self.FEDERATION_AUTH_URL = '%s/%s' % (
            self.TEST_URL,
            'OS-FEDERATION/identity_providers/testidp/protocols/saml2/auth')
        self.SHIB_CONSUMER_URL = ('https://openstack4.local/'
                                  'Shibboleth.sso/SAML2/ECP')

        self.saml2plugin = saml2.Saml2UnscopedToken(self.TEST_URL,
                                                    self.IDENTITY_PROVIDER,
                                                    self.IDENTITY_PROVIDER_URL,
                                                    self.TEST_USER,
                                                    self.TEST_TOKEN)