<commit_before>lizard-auth-client
==========================================

Based on the Django Simple SSO project (https://github.com/ojii/django-simple-sso). MIT license.


Usage
-----

Include this app as a dependecy in setup.py::

  install_requires = [
      'lizard-auth-client',
  ],

Add it in your INSTALLED_APPS::

  INSTALLED_APPS = (
      'lizard_auth_client',
  )

Configure the SSO settings as seen in ``testsettings.py``::

  # SSO
  SSO_STANDALONE = True
  # A key identifying this client. Can be published.
  SSO_KEY = 'random_generated_key_to_identify_the_client'
  # A *secret* shared between client and server. Used to sign the messages exchanged between them.
  SSO_SECRET = 'random_generated_secret_key_to_sign_exchanged_messages'
  # URL used to redirect the user to the SSO server
  # Note: needs a trailing slash
  SSO_SERVER_PUBLIC_URL = 'http://external-address.site.tld/'
  # URL used for server-to-server communication
  # Note: needs a trailing slash
  SSO_SERVER_PRIVATE_URL = 'http://10.0.0.1:80/'

Add the proper URLS to your urls.py. Because the app needs to override the login/logout URLS,
import them in the root of your urlpatterns::

  urlpatterns = patterns(
      '',
      (r'^', include('lizard_auth_client.urls')),
  )<commit_msg>add some custom auth help<commit_after>lizard-auth-client
==========================================

Based on the Django Simple SSO project (https://github.com/ojii/django-simple-sso). MIT license.


Usage
-----

Include this app as a dependecy in setup.py::

  install_requires = [
      'lizard-auth-client',
  ],

Add it in your INSTALLED_APPS::

  INSTALLED_APPS = (
      'lizard_auth_client',
  )

Configure the SSO settings as seen in ``testsettings.py``::

  # SSO
  SSO_STANDALONE = True
  # A key identifying this client. Can be published.
  SSO_KEY = 'random_generated_key_to_identify_the_client'
  # A *secret* shared between client and server. Used to sign the messages exchanged between them.
  SSO_SECRET = 'random_generated_secret_key_to_sign_exchanged_messages'
  # URL used to redirect the user to the SSO server
  # Note: needs a trailing slash
  SSO_SERVER_PUBLIC_URL = 'http://external-address.site.tld/'
  # URL used for server-to-server communication
  # Note: needs a trailing slash
  SSO_SERVER_PRIVATE_URL = 'http://10.0.0.1:80/'

Add the proper URLS to your urls.py. Because the app needs to override the login/logout URLS,
import them in the root of your urlpatterns::

  urlpatterns = patterns(
      '',
      (r'^', include('lizard_auth_client.urls')),
  )


Custom authentication
-----

In a Django context, simple configure the app as above, and do:

  from lizard_auth_client import client as auth_client
  try:
    user_data = auth_client.sso_authenticate_django('username', 'password')
  except auth_client.AutheticationFailed as ex:
    return some_error_handler('Auth failed')
  except auth_client.CommunicationError as ex:
    return some_error_handler('Temporary comm error')
  except:
    return some_error_handler('Other error')

It should be usable without Django settings as well:

    user_data = auth_client.sso_authenticate('http://url.tld', 'key', 'secret' 'username', 'password')
{'fraction_non_alphanumeric': 0.11762870514820593, 'fraction_numerical': 0.00436817472698908, 'mean_word_length': 4.072784810126582, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '553994', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1000, 'n_words': 310}