Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack LLC # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License.
except ImportError: pam = None import PAM
def _pam_conv(auth, query_list): resp = []
for query, q_type in query_list: if q_type in [PAM.PAM_PROMPT_ECHO_ON, PAM.PAM_PROMPT_ECHO_OFF]: resp.append((password, 0)) elif q_type in [PAM.PAM_PROMPT_ERROR_MSG, PAM.PAM_PROMPT_TEXT_INFO]: resp.append(('', 0))
return resp
auth = PAM.pam() auth.start('passwd') auth.set_item(PAM.PAM_USER, username) auth.set_item(PAM.PAM_CONV, _pam_conv)
try: auth.authenticate() auth.acct_mgmt() except PAM.error: raise AssertionError('Invalid user / password')
return True
"""Very basic identity based on PAM.
Tenant is always the same as User, root user has admin role. """
auth = pam.authenticate if pam else PAM_authenticate if not auth(user_id, password): raise AssertionError('Invalid user / password') user = {'id': user_id, 'name': user_id} return user
user_id = user_ref['id'] metadata = {} if user_id == 'root': metadata['is_admin'] = True tenant = {'id': user_id, 'name': user_id} return (user_ref, tenant, metadata)
# TODO(henry-nash): Used domain_id once domains are implemented # in LDAP backend
# TODO(henry-nash): Used domain_id once domains are implemented # in LDAP backend
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
pass
pass
return [user_id]
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError()
raise NotImplementedError() |