Skip to content

Commit

Permalink
Add Kerberos (GSSAPI) Authentication Method
Browse files Browse the repository at this point in the history
This adds GSSAPI as an authentication method for using keytabs and
Kerberos SSO to authenticate against the core endpoints.

Fix pacifica/pacifica-python-uploader#36

Signed-off-by: David Brown <dmlb2000@gmail.com>
  • Loading branch information
dmlb2000 committed Jan 29, 2020
1 parent 611248b commit 217cdd7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/exampleusage.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ There are three kinds of authentication types supported.
- clientssl - This is where you have an SSL client key and cert
- basic - This is a username and password
- gssapi - Use GSSAPI tickets to authenticate
- None - Do not perform any authentication
Authentication Type (None): basic
Expand Down
3 changes: 2 additions & 1 deletion pacifica/cli/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ def configure_auth(global_ini):
- clientssl - This is where you have an SSL client key and cert
- basic - This is a username and password
- gssapi - Use GSSAPI tickets to authenticate
- None - Do not perform any authentication
""")
default_auth_type = global_ini.get('authentication', 'type')
stdout.write('Authentication Type ({}): '.format(default_auth_type))
stdout.flush()
strip_input = stdin.readline().strip()
if strip_input and strip_input in ['clientssl', 'basic', 'None']:
if strip_input and strip_input in ['clientssl', 'basic', 'gssapi', 'None']:
global_ini.set('authentication', 'type', strip_input)
auth_type = global_ini.get('authentication', 'type')
if auth_type == 'clientssl':
Expand Down
12 changes: 12 additions & 0 deletions pacifica/cli/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from getpass import getuser
from os import environ, getenv
from os.path import isfile
import warnings
from json import loads
import requests
from pacifica.uploader.uploader import LOGGER as UP_LOGGER
Expand Down Expand Up @@ -142,6 +143,17 @@ def generate_requests_auth(global_ini):
global_ini.get('authentication', 'key')
)
}
elif auth_type == 'gssapi': # pragma: no cover don't have kerberos available to test with
# pylint: disable=import-outside-toplevel
try:
from requests_gssapi import HTTPSPNEGOAuth
except ImportError as ex:
warnings.warn('Unable to import requests_gssapi please `pip install requests_gssapi`')
raise ex
# pylint: enable=import-outside-toplevel
ret = {
'auth': HTTPSPNEGOAuth()
}
elif auth_type == 'basic':
ret = {
'auth': (
Expand Down
4 changes: 4 additions & 0 deletions tests/methods_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def test_gen_req_auth(self):
self.assertTrue(generate_requests_auth(conf)
['auth'][0], 'username')
self.assertTrue(generate_requests_auth(conf)['auth'], 'password')
with ConfigClient('gssapi') as conf:
with self.assertRaises(ImportError) as excinfo:
generate_requests_auth(conf)
self.assertTrue('No module named' in excinfo.exception.msg)

def test_verify_type(self):
"""Test the verify_type method to cover everything."""
Expand Down

0 comments on commit 217cdd7

Please sign in to comment.