Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Add keycloak provider #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion awsprocesscreds/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def saml(argv=None, prompter=getpass.getpass, client_creator=None,
help='Your SAML username.'
)
parser.add_argument(
'-p', '--provider', required=True, choices=['okta', 'adfs'],
'-p', '--provider', required=True, choices=['okta', 'adfs', 'keycloak'],
help=(
'The name of your SAML provider. Currently okta and adfs '
'form-based auth is supported.'
Expand Down
14 changes: 12 additions & 2 deletions awsprocesscreds/saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@ def is_suitable(self, config):
return (config.get('saml_authentication_type') == 'form' and
config.get('saml_provider') == 'adfs')

class KeycloakAuthenticator(GenericFormsBasedAuthenticator):
USERNAME_FIELD = 'username'
PASSWORD_FIELD = 'password'

def is_suitable(self, config):
return (config.get('saml_authentication_type') == 'form' and
config.get('saml_provider') == 'keycloak')


class FormParser(six.moves.html_parser.HTMLParser):
def __init__(self):
Expand All @@ -287,6 +295,8 @@ def _dict2str(self, d):
# so that the output will be suitable to be fed into an ET later.
parts = []
for k, v in d.items():
if v == None:
v = 'true'
escaped_value = escape(v) # pylint: disable=deprecated-method
parts.append('%s="%s"' % (k, escaped_value))
return ' '.join(sorted(parts))
Expand All @@ -308,8 +318,8 @@ def error(self, message):
class SAMLCredentialFetcher(CachedCredentialFetcher):
SAML_FORM_AUTHENTICATORS = {
'okta': OktaAuthenticator,
'adfs': ADFSFormsBasedAuthenticator

'adfs': ADFSFormsBasedAuthenticator,
'keycloak': KeycloakAuthenticator
}

def __init__(self, client_creator, provider_name, saml_config,
Expand Down