Make an `Origin` by logging-in with a username and password.

        :return: A tuple of ``profile`` and ``origin``, where the former is an
            unsaved `Profile` instance, and the latter is an `Origin` instance
            made using the profile.
430098
async def login(
            cls, url, *, username=None, password=None, insecure=False):
        
        profile, session = await bones.SessionAPI.login(
            url=url, username=username, password=password, insecure=insecure)
        return profile, cls(session)
1057528
def allow_origin_tween_factory(handler, registry):
    
    def allow_origin_tween(request):
        settings = request.registry.settings
        request_origin = request.headers.get('origin')

        def is_origin_allowed(origin):
            allowed_origins = (
                request.registry.settings.get('api.allowed_origins', [])
            )
            if isinstance(allowed_origins, str):
                allowed_origins = allowed_origins.splitlines()
            if not origin:
                return False
            for allowed_origin in allowed_origins:
                if origin.lower().startswith(allowed_origin):
                    return True
            return False

        def allow_origin_callback(request, response):
            """Set access-control-allow-origin et. al headers

            """
            allowed_methods = settings.get(
                'api.allowed_methods',
                str('GET, POST, PUT, DELETE, PATCH, OPTIONS'),
            )
            if callable(allowed_methods):
                allowed_methods = allowed_methods(request)

            allowed_headers = settings.get(
                'api.allowed_headers',
                str('Content-Type, Authorization, Range'),
            )
            if callable(allowed_headers):
                allowed_headers = allowed_headers(request)

            allowed_credentials = settings.get(
                'api.allowed_credentials',
                str('true'),
            )
            if callable(allowed_credentials):
                allowed_credentials = allowed_credentials(request)

            response.headers['Access-Control-Allow-Origin'] = request_origin
            if allowed_credentials:
                response.headers[str('Access-Control-Allow-Credentials')] = \
                    str(allowed_credentials)
            if allowed_methods:
                response.headers[str('Access-Control-Allow-Methods')] = str(
                    allowed_methods,
                )
            if allowed_headers:
                response.headers[str('Access-Control-Allow-Headers')] = str(
                    allowed_headers,
                )

        if not is_origin_allowed(request_origin):
            return handler(request)

        request.add_response_callback(allow_origin_callback)
        return handler(request)
    return allow_origin_tween
1299789
def make_primary(self, user, identity):
        
        return UserIdentityRequest(self).put(self.endpoint.make_primary, user, identity)
290495
def _auth(profile=None):
    '''
    
    '''
    credentials = __salt__['config.option'](profile)
    kwargs = {
        'username': credentials['keystone.user'],
        'password': credentials['keystone.password'],
        'tenant_name': credentials['keystone.tenant'],
        'auth_url': credentials['keystone.auth_url'],
        'region_name': credentials.get('keystone.region_name', None),
        'service_type': credentials['keystone.service_type'],
    }

    return suoneu.SaltNeutron(**kwargs)
1267792
def _callback_factory(callback_imp):
    """"""
    if callback_imp is None:
        try:
            pkg_resources.get_distribution('flask-login')
            from flask_login import current_user
            return lambda: current_user.is_authenticated
        except pkg_resources.DistributionNotFound:
            return lambda: False
    elif isinstance(callback_imp, string_types):
        return import_string(callback_imp)
    else:
        return callback_imp
888149
def get_identifier(self, origin=None):
        

        token = self.get().unescape()
        if not token.is_identifier():
            raise dns.exception.SyntaxError('expecting an identifier')
        return token.value
1158250
def origin(hosts):
    

    hosts = [urlsplit(h) for h in hosts]

    def func(environ):
        if 'ISSO_CORS_ORIGIN' in environ:
            return environ['ISSO_CORS_ORIGIN']

        if not hosts:
            return "http://invalid.local"

        loc = environ.get("HTTP_ORIGIN", environ.get("HTTP_REFERER", None))

        if loc is None:
            return urljoin(*hosts[0])

        for split in hosts:
            if urlsplit(loc) == split:
                return urljoin(*split)
        else:
            return urljoin(*hosts[0])

    return func
450349
def create_token(credential, opts = {})
      data, _status_code, _headers = create_token_with_http_info(credential, opts)
      return data
    end
965422
def profile(request):
    '''
        
    '''
    context = {}

    if request.method == 'POST':
        form = PasswordChangeForm(request.user, request.POST)
        if form.is_valid():
            form.save()
            messages.info(request, 'Password Changed.')
    else:
        form = PasswordChangeForm(request.user)

    key = Key.objects.get(email=request.user.email)
    
    #analytics
    endpoint_q = key.reports.values('api__name', 'endpoint').annotate(calls=Sum('calls')).order_by('-calls')
    endpoints = [{'endpoint':'.'.join((d['api__name'], d['endpoint'])),
                  'calls': d['calls']} for d in endpoint_q]
    date_q = key.reports.values('date').annotate(calls=Sum('calls')).order_by('date')
    context['endpoints'], context['endpoint_calls'] = _dictlist_to_lists(endpoints, 'endpoint', 'calls')
    context['timeline'] = date_q

    context['form'] = form
    context['key'] = key
    context['password_is_key'] = request.user.check_password(key.key)
    return render_to_response('locksmith/profile.html', context,
                              context_instance=RequestContext(request))
193356
def allow_origin(self, request):
        # type: (BaseHttpRequest) -> str
        
        origins = self.origins
        if origins is AnyOrigin:
            return '*'
        else:
            origin = request.origin
            return origin if origin in origins else ''
247374
def _get_profile(self):
        
        url = PROFILE_URL + self.hash + '.json'
        try:
            profile = json.load(urlopen(url))
            # set the profile as an instance variable
            self._profile = profile['entry'][0]
        except:
            self._profile = {}
1019797
def process_origin(
        headers: Headers, origins: Optional[Sequence[Optional[Origin]]] = None
    ) -> Optional[Origin]:
        
        # "The user agent MUST NOT include more than one Origin header field"
        # per https://tools.ietf.org/html/rfc6454#section-7.3.
        try:
            origin = cast(Origin, headers.get("Origin"))
        except MultipleValuesError:
            raise InvalidHeader("Origin", "more than one Origin header found")
        if origins is not None:
            if origin not in origins:
                raise InvalidOrigin(origin)
        return origin
72217
def _makeStoreOwnerPerson(self):
        
        if self.store is None:
            return None
        userInfo = self.store.findFirst(signup.UserInfo)
        name = u''
        if userInfo is not None:
            name = userInfo.realName
        account = self.store.findUnique(LoginAccount,
                                        LoginAccount.avatars == self.store, None)
        ownerPerson = self.createPerson(name)
        if account is not None:
            for method in (self.store.query(
                    LoginMethod,
                    attributes.AND(LoginMethod.account == account,
                                   LoginMethod.internal == False))):
                self.createContactItem(
                    EmailContactType(self.store),
                    ownerPerson, dict(
                        email=method.localpart + u'@' + method.domain))
        return ownerPerson
440392
def get_profile_for_user(user):
    
    if not hasattr(user, '_yacms_profile'):
        # Raises ProfileNotConfigured if not bool(ACCOUNTS_PROFILE_MODEL)
        profile_model = get_profile_model()
        profile_manager = profile_model._default_manager.using(user._state.db)

        user_field = get_profile_user_fieldname(profile_model, user.__class__)
        profile, created = profile_manager.get_or_create(**{user_field: user})

        profile.user = user
        user._yacms_profile = profile

    return user._yacms_profile
438011
def create_user(self, instance, name, password, database_names, host=None):
        
        return instance.create_user(name=name, password=password,
                database_names=database_names, host=host)
575054
def create_for_user(self, user):
        
        # support passing email address too
        if type(user) is unicode:
            from .profile import Profile as User
            user = User.objects.get(email=user)

        temp_key = token_generator.make_token(user)

        # save it to the password reset model
        password_reset = PasswordReset(user=user, temp_key=temp_key)
        password_reset.save()

        # send the password reset email
        subject = _("Password reset email sent")
        message = render_to_string("profiles/email_messages/password_reset_key_message.txt", {
            "user": user,
            "uid": int_to_base36(user.id),
            "temp_key": temp_key,
            "site_url": settings.SITE_URL,
            "site_name": settings.SITE_NAME
        })
        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email])

        return password_reset
1300216
def origin=(new_origin)
      if new_origin
        if !new_origin.respond_to?(:to_str)
          raise TypeError, "Can't convert #{new_origin.class} into String."
        end
        new_origin = new_origin.to_str
        new_scheme = new_origin[/^([^:\/?#]+):\/\//, 1]
        unless new_scheme
          raise InvalidURIError, 'An origin cannot omit the scheme.'
        end
        new_host = new_origin[/:\/\/([^\/?#:]+)/, 1]
        unless new_host
          raise InvalidURIError, 'An origin cannot omit the host.'
        end
        new_port = new_origin[/:([^:@\[\]\/]*?)$/, 1]
      end

      self.scheme = defined?(new_scheme) ? new_scheme : nil
      self.host = defined?(new_host) ? new_host : nil
      self.port = defined?(new_port) ? new_port : nil
      self.userinfo = nil

      # Reset dependent values
      remove_instance_variable(:@userinfo) if defined?(@userinfo)
      remove_instance_variable(:@normalized_userinfo) if defined?(@normalized_userinfo)
      remove_instance_variable(:@authority) if defined?(@authority)
      remove_instance_variable(:@normalized_authority) if defined?(@normalized_authority)
      remove_composite_values

      # Ensure we haven't created an invalid URI
      validate()
    end