示例#1
0
# License for the specific language governing permissions and limitations
# under the License.
"""Main entry point into the Token service."""

import datetime

from keystone.common import cms
from keystone.common import dependency
from keystone.common import logging
from keystone.common import manager
from keystone import config
from keystone import exception
from keystone.openstack.common import timeutils

CONF = config.CONF
config.register_int('expiration', group='token', default=86400)
LOG = logging.getLogger(__name__)


def unique_id(token_id):
    """Return a unique ID for a token.

    The returned value is useful as the primary key of a database table,
    memcache store, or other lookup table.

    :returns: Given a PKI token, returns it's hashed value. Otherwise, returns
              the passed-in value (such as a UUID token ID or an existing
              hash).
    """
    return cms.cms_hash_token(token_id)
示例#2
0
import base64
import hashlib
import hmac
import json
import subprocess
import sys
import urllib

import bcrypt

from keystone import config
from keystone.common import logging

CONF = config.CONF
config.register_int('bcrypt_strength', default=12)


def import_class(import_str):
    """Returns a class from a string including module and class."""
    mod_str, _sep, class_str = import_str.rpartition('.')
    try:
        __import__(mod_str)
        return getattr(sys.modules[mod_str], class_str)
    except (ImportError, ValueError, AttributeError), exc:
        logging.debug('Inner Exception: %s', exc)
        raise


def import_object(import_str, *args, **kw):
    """Returns an object including a module or module and class."""
示例#3
0
文件: core.py 项目: a3linux/keystone
# License for the specific language governing permissions and limitations
# under the License.

"""Main entry point into the Token service."""

import datetime

from keystone.common import manager
from keystone.common import cms
from keystone import config
from keystone import exception
from keystone.openstack.common import timeutils


CONF = config.CONF
config.register_int('expiration', group='token', default=86400)


class Manager(manager.Manager):
    """Default pivot point for the Token backend.

    See :mod:`keystone.common.manager.Manager` for more details on how this
    dynamically calls the backend.

    """

    def __init__(self):
        super(Manager, self).__init__(CONF.token.driver)

    def revoke_tokens(self, context, user_id, tenant_id=None):
        """Invalidates all tokens held by a user (optionally for a tenant).
示例#4
0
import copy

import memcache

from keystone.common import logging
from keystone.common import utils
from keystone import config
from keystone import exception
from keystone.openstack.common import jsonutils
from keystone.openstack.common import timeutils
from keystone import token


CONF = config.CONF
config.register_str('servers', group='memcache', default='localhost:11211')
config.register_int('max_compare_and_set_retry', group='memcache', default=16)

LOG = logging.getLogger(__name__)


class Token(token.Driver):
    revocation_key = 'revocation-list'

    def __init__(self, client=None):
        self._memcache_client = client

    @property
    def client(self):
        return self._memcache_client or self._get_memcache_client()

    def _get_memcache_client(self):
示例#5
0
import hmac
import json
import os
import subprocess
import time
import urllib

import passlib.hash

from keystone.common import logging
from keystone import config
from keystone import exception


CONF = config.CONF
config.register_int('crypt_strength', default=40000)

LOG = logging.getLogger(__name__)

MAX_PASSWORD_LENGTH = 4096


def read_cached_file(filename, cache_info, reload_func=None):
    """Read from a file if it has been modified.

    :param cache_info: dictionary to hold opaque cache.
    :param reload_func: optional function to be called with data when
                        file is reloaded due to a modification.

    :returns: data from file.
示例#6
0
import base64
import hashlib
import hmac
import json
import subprocess
import sys
import urllib

import bcrypt

from keystone import config
from keystone.common import logging


CONF = config.CONF
config.register_int('bcrypt_strength', default=12)


def import_class(import_str):
    """Returns a class from a string including module and class."""
    mod_str, _sep, class_str = import_str.rpartition('.')
    try:
        __import__(mod_str)
        return getattr(sys.modules[mod_str], class_str)
    except (ImportError, ValueError, AttributeError), exc:
        logging.debug('Inner Exception: %s', exc)
        raise


def import_object(import_str, *args, **kw):
    """Returns an object including a module or module and class."""
示例#7
0
import base64
import hashlib
import hmac
import json
import subprocess
import sys
import urllib

import bcrypt

from keystone import config
from keystone.common import logging


CONF = config.CONF
config.register_int("bcrypt_strength", default=12)


def import_class(import_str):
    """Returns a class from a string including module and class."""
    mod_str, _sep, class_str = import_str.rpartition(".")
    try:
        __import__(mod_str)
        return getattr(sys.modules[mod_str], class_str)
    except (ImportError, ValueError, AttributeError), exc:
        logging.debug("Inner Exception: %s", exc)
        raise


def import_object(import_str, *args, **kw):
    """Returns an object including a module or module and class."""
示例#8
0
文件: core.py 项目: 0xffea/keystone
"""Main entry point into the Token service."""

import datetime

from keystone.common import cms
from keystone.common import dependency
from keystone.common import logging
from keystone.common import manager
from keystone import config
from keystone import exception
from keystone.openstack.common import timeutils


CONF = config.CONF
config.register_int("expiration", group="token", default=86400)
LOG = logging.getLogger(__name__)


def unique_id(token_id):
    """Return a unique ID for a token.

    The returned value is useful as the primary key of a database table,
    memcache store, or other lookup table.

    :returns: Given a PKI token, returns it's hashed value. Otherwise, returns
              the passed-in value (such as a UUID token ID or an existing
              hash).
    """
    return cms.cms_hash_token(token_id)
示例#9
0
import base64
import hashlib
import hmac
import json
import os
import subprocess
import time
import urllib

import passlib.hash

from keystone.common import logging
from keystone import config

CONF = config.CONF
config.register_int('crypt_strength', default=40000)

LOG = logging.getLogger(__name__)

MAX_PASSWORD_LENGTH = 4096


def read_cached_file(filename, cache_info, reload_func=None):
    """Read from a file if it has been modified.

    :param cache_info: dictionary to hold opaque cache.
    :param reload_func: optional function to be called with data when
                        file is reloaded due to a modification.

    :returns: data from file
示例#10
0
from __future__ import absolute_import
import copy

import memcache

from keystone.common import logging
from keystone.common import utils
from keystone import config
from keystone import exception
from keystone.openstack.common import jsonutils
from keystone.openstack.common import timeutils
from keystone import token

CONF = config.CONF
config.register_str('servers', group='memcache', default='localhost:11211')
config.register_int('max_compare_and_set_retry', group='memcache', default=16)

LOG = logging.getLogger(__name__)


class Token(token.Driver):
    revocation_key = 'revocation-list'

    def __init__(self, client=None):
        self._memcache_client = client

    @property
    def client(self):
        return self._memcache_client or self._get_memcache_client()

    def _get_memcache_client(self):