コード例 #1
0
    def get(self, key=None):
        principal = self.get_argument("principal", None)

        #
        # it's only valid to ask for a specific set of credentials
        # (ie key != None) **or** all the credentials associated with
        # a specific principal.
        #
        if (not key and not principal) or (key and principal):
            self.set_status(httplib.BAD_REQUEST)
            self.finish()
            return

        acr = AsyncCredsRetriever(_key_store)
        acr.fetch(
            self._on_async_creds_retrieve_done,
            key=key,
            principal=principal,
            is_filter_out_non_model_properties=True)
コード例 #2
0
ファイル: async_auth.py プロジェクト: simonsdave/yar
    def authenticate(self, on_auth_done):
        self._on_auth_done = on_auth_done

        auth_hdr_val = self._request.headers.get("Authorization", None)
        if auth_hdr_val is None:
            self._on_auth_done(False, AUTH_FAILURE_DETAIL_NO_AUTH_HEADER)
            return

        match = _auth_hdr_val_reg_ex.match(auth_hdr_val)
        if not match:
            self._on_auth_done(
                False,
                AUTH_FAILURE_DETAIL_INVALID_AUTH_HEADER_FORMAT_PRE_DECODING)
            return

        b64encoded_api_key_colon = match.group("api_key_colon")

        try:
            api_key_colon = base64.b64decode(b64encoded_api_key_colon)
        except TypeError:
            self._on_auth_done(
                False,
                AUTH_FAILURE_DETAIL_INVALID_AUTH_HEADER_BAD_ENCODING)
            return

        match = _api_key_colon_reg_ex.match(api_key_colon)
        if not match:
            self._on_auth_done(
                False,
                AUTH_FAILURE_DETAIL_INVALID_AUTH_HEADER_FORMAT_POST_DECODING)
            return

        self._api_key = match.group("api_key")

        acr = AsyncCredsRetriever(self._api_key)
        acr.fetch(self._on_creds_fetch_done)
コード例 #3
0
ファイル: async_creds_deleter.py プロジェクト: simonsdave/yar
    def delete(self, key, callback):
        self._callback = callback

        acr = AsyncCredsRetriever(self.key_store)
        acr.fetch(self._on_async_creds_retriever_done, key=key)