Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Right now the login methods cannot be "plugged in", but you can add another oauth2 provider similarly to how "facebook" login is implemented (talking about the code from the askbot's github repository).

Right now It is possible by implementing a special module and adding python path to that module in the settings.py file:

ASKBOT_CUSTOM_AUTH_MODULE = 'myapp.my_login_method' #the app must be on the python path

Only one custom method is supported at the moment per site.

The module can have the following variables:

BIG_BUTTON - optional, boolean, True|False, default=True, if true, button will be big)
ORDER_NUMBER - optional, integer, default=1, position in the row of buttons)
NAME
DISPLAY_NAME
ICON_MEDIA_PATH (required, string, url to the image of the login methods cannot be "plugged in", button)
TOOLTIP_TEXT (required, string, tooltip text to show on mouse hover over the button)

For password logins the following module settings are available:

TYPE = 'password' #identifies login method as using the password protocol
CREATE_PASSWORD_PROMPT - required, string, text to be displayed in the UI
CHANGE_PASSWORD_PROMPT - required, string, text to be displayed in the UI
EXTRA_TOKEN_NAME - required, string, text to be displayed above the login form
check_password - required, function, returns boolean, takes login name and password as parameters

If you have doubts about your own implementation of OpenID and especially OAuth and OAuth2 logins, please have a look into the file askbot/deps/django_authopenid/util.py (This does need to be split into per-protocol files, but you can add another oauth2 provider similarly to how "facebook" as of version 0.7.50 that code lives there).

For OpenID logins the following setting is available:

TYPE - required, string, 'openid-direct'|'openid-username', use the last value if username is required beforehand)
OPENID_ENDPOINT - openid endpoint url, if TYPE='openid-username'
EXTRA_TOKEN_NAME - only for TYPE='openid-username', string, text to show above the user name input

For OAuth (version 1) logins the following settings are available, all are required:

TYPE = 'oauth'
OAUTH_CONSUMER_KEY - this and the following four parameters url string values
OAUTH_CONSUMER_SECRET
OAUTH_REQUEST_TOKEN_URL
OAUTH_ACCESS_TOKEN_URL
OAUTH_AUTHORIZE_URL
oauth_get_user_id_function - function, returns remote user id, parameter dictionary returned by 
the access token request (using the `oauth2` module - not to be confused with the OAuth2 
protocol as this module is actually OAuth1, but the name is confusing

See examples in `askbot/deps/django_authopenid/util.py ` for the Twitter and LinkedIn login is implemented (talking about the code from the askbot's github repository).

implementations.

For AOuth2 logins the following settings are available:

TYPE = 'oauth2'
OAUTH_ENDPOINT
OAUTH_TOKEN_ENDPOINT
OAUTH_RESOURCE_ENDPOINT
oauth_get_user_id_function - required, function, returns remote user id, 
                                             parameter - instance of `sanction.client.Client`
                                             after the request token is obtained
response_parser - required, parser function for the `sanction.client.Client.request_token` call
token_transport - required, `token_transport` parameter of the `sanction.client.Client` initialization

See examples in `askbot/deps/django_authopenid/util.py` (e.g. Facebook or Google+ login methods)

It is possible by implementing a special module and adding python path to that module in the settings.py file:

ASKBOT_CUSTOM_AUTH_MODULE = 'myapp.my_login_method' #the app must be on the python path

Only one custom method is supported at the moment per site.

The module can have the following variables:

BIG_BUTTON - optional, boolean, True|False, default=True, if true, button will be big)
big
ORDER_NUMBER - optional, integer, default=1, position in the row of buttons)
buttons
NAME
DISPLAY_NAME
ICON_MEDIA_PATH (required, - required, string, url to the image of the login button)
button
TOOLTIP_TEXT (required, - required, string, tooltip text to show on mouse hover over the button)
button

For password logins the following module settings are available:

TYPE = 'password' #identifies login method as using the password protocol
CREATE_PASSWORD_PROMPT - required, string, text to be displayed in the UI
CHANGE_PASSWORD_PROMPT - required, string, text to be displayed in the UI
EXTRA_TOKEN_NAME - required, string, text to be displayed above the login form
check_password - required, function, returns boolean, takes login name and password as parameters

If you have doubts about your own implementation of OpenID and especially OAuth and OAuth2 logins, please have a look into the file askbot/deps/django_authopenid/util.py (This does need to be split into per-protocol files, but as of version 0.7.50 that code lives there).

For OpenID logins the following setting is available:

TYPE - required, string, 'openid-direct'|'openid-username', use the last value if username is required beforehand)
OPENID_ENDPOINT - openid endpoint url, if TYPE='openid-username'
EXTRA_TOKEN_NAME - only for TYPE='openid-username', string, text to show above the user name input

For OAuth (version 1) logins the following settings are available, all are required:

TYPE = 'oauth'
OAUTH_CONSUMER_KEY - this and the following four parameters url string values
OAUTH_CONSUMER_SECRET
OAUTH_REQUEST_TOKEN_URL
OAUTH_ACCESS_TOKEN_URL
OAUTH_AUTHORIZE_URL
oauth_get_user_id_function - function, returns remote user id, parameter dictionary returned by 
the access token request (using the `oauth2` module - not to be confused with the OAuth2 
protocol as this module is actually OAuth1, but the name is confusing

See examples in `askbot/deps/django_authopenid/util.py ` for the Twitter and LinkedIn login implementations.

For AOuth2 logins the following settings are available:

TYPE = 'oauth2'
OAUTH_ENDPOINT
OAUTH_TOKEN_ENDPOINT
OAUTH_RESOURCE_ENDPOINT
oauth_get_user_id_function - required, function, returns remote user id, 
                                             parameter - instance of `sanction.client.Client`
                                             after the request token is obtained
response_parser - required, parser function for the `sanction.client.Client.request_token` call
token_transport - required, `token_transport` parameter of the `sanction.client.Client` initialization

See examples in `askbot/deps/django_authopenid/util.py` (e.g. Facebook or Google+ login methods)