| Wrapper
Class
|
The wrapper must be implemented as a class (referred to here as
AuthCl), with requirements as shown in the following
table.
| Required data members for
AuthCl |
| name
|
A short descriptive name for the authenticator, as a
string. This will be used as the Type value for the
resulting authentication service. It should uniquely
identify the plug-in. |
|
Required method for AuthCl: at least one of the
following.
|
get_user(
- self,
- username,
- password,
- conf_data )
|
Identifies a hub user based on a username and password,
in combination with any data obtained through the
plug-in's HTML fragment.
| username
|
is the username string provided. |
| password
|
is the password string provided. |
| conf_data
|
is a tuple containing any information gathered
from the form fields of the HTML fragement you
designed in Step 2.. |
get_user(uname, passwd,
cdata) returns:
- a dict with required key
'user' and optional keys 'email', 'roles' if the
uname/passwd combination is valid with
respect to cdata.
- 'user'
: the "canonical user name" according to
the authentication service. It must be a nonempty
string. This value will match the Username
for the corresponding hub user
account.
- 'email' : [optional]
the email address that the authentication service
associates with the user. If the hub user account
Email
has
special value NULL, it will be updated to this
value. Set to None
if there is no such address (or if the author does
not want to pass it to CodeSonar).
-
'roles'
: [optional] the
names of the roles
that should be associated with the user on behalf
of this plug-in, as an iterable of str.
When a user logs in with username and password
through the plug-in, these role names are used to
update their hub user account Roles
as follows.
- All the named roles that were not already
assigned are added.
- If the user was not already assigned a
given role, the hub will also record that
the assignment for that role was performed
by this plug-in.
- If there is no role corresponding to a
particular name, that name is ignored.
- Roles that were previously added by this
plug-in but do not appear on the list are
removed.
- None if the
uname/passwd combination is not
valid with respect to cdata.
If a problem occurs, get_user() should raise an
AuthException.
|
get_user_from_cert(
- self,
- client_cert,
- client_cert_dict,
- conf_data )
|
Identifies a hub user based on a TLS certificate, in
combination with any data obtained through the
plug-in's HTML fragment.
| client_cert
|
is the TLS certificate provided, in raw (DER)
binary encoding. Note that the hub will already have
checked that this certificate is trusted by the
hub's client
authentication certificate and rejected the
authentication attempt if it is not trusted. |
| client_cert_dict
|
is a dict containing information parsed from
client_cert. |
| conf_data
|
is a tuple containing any information gathered
from the form fields of the HTML fragement you
designed in Step 2. |
get_user_from_cert(cert,
cert_dict, cdata) returns:
- a dict with required key
'user' and optional keys 'email', 'roles' if cert is valid with respect to
cdata.
- 'user'
: the "canonical user name" according to
the authentication service. It must be a nonempty
string. This value will match the Username
for the corresponding hub user
account.
- 'email' : [optional]
the email address that the authentication service
associates with the user. If the hub user account
Email
has
special value NULL, it will be updated to this
value. Set to None
if there is no such address (or if the author does
not want to pass it to CodeSonar).
-
'roles'
: [optional] the
names of the roles
that should be associated with the user on behalf
of this plug-in, as an iterable of str.
When a user logs in with username and password
through the plug-in, these role names are used to
update their hub user account Roles
as follows.
- All the named roles that were not already
assigned are added.
- If the user was not already assigned a
given role, the hub will also record that
the assignment for that role was performed
by this plug-in.
- If there is no role corresponding to a
particular name, that name is ignored.
- Roles that were previously added by this
plug-in but do not appear on the list are
removed.
- None if
cert is not
valid with respect to cdata.
If a problem occurs, get_user_from_cert() should raise an
AuthException.
|
get_user_from_request(
- self,
- acs_url,
- post_data,
- conf_data )
|
Identifies a hub user based on the POST request returned
by a Single Sign On (SSO) Identity Provider
(IdP) to the hub upon successful authentication.
| acs_url
|
is the Assertion Consumer Service URL to which
the IdP just sent the POST request. This will be a
URL on the hub. The acs_url is provided in
case it is required to validate or interpret the
post_data argument. |
| post_data
|
is a dict of the
data from the POST request issued by the IdP on
successful hub authentication.
The IdP will need to be configured to include in this
POST request any data expected by your authenticator.
In particular, the POST request should include
sufficient data to allow your get_user_from_request()
implementation to populate the returned dict. |
| conf_data
|
is a tuple containing any information gathered
from the form fields of the HTML fragement you
designed in Step 2. |
get_user_from_request(rurl,
rpostdata, rconfdata) returns:
- a dict with
required key 'user', and optional keys
'email',
'sso_id',
'expiry',
'roles' if the
combination of rurl
and rpostdata
represents successful SSO authentication for the hub.
- 'user'
: a nonempty string that will match the Username
for the corresponding hub user
account.
- 'email' : [optional]
the email address associated with the user. If the
hub user account Email
has
special value NULL, it will be updated to this
value. Set to None
if there is no such address (or if you do not want
to pass it to CodeSonar).
- 'sso_id' : [optional]
the ID of the SSO request.
- 'expiry' : [optional]
a datetime object
representing when the SSO request expires. If this
is None,
authentication will expire a day after the request
was received.
-
'roles'
: [optional] the
names of the roles
that should be associated with the user on behalf
of this plug-in, as an iterable of str.
When a user logs in with username and password
through the plug-in, these role names are used to
update their hub user account Roles
as follows.
- All the named roles that were not already
assigned are added.
- If the user was not already assigned a
given role, the hub will also record that
the assignment for that role was performed
by this plug-in.
- If there is no role corresponding to a
particular name, that name is ignored.
- Roles that were previously added by this
plug-in but do not appear on the list are
removed.
- raises AuthException if authentication
failed.
If a problem occurs, get_user_from_request() should raise
an AuthException.
|
sso_redirect(
- self,
- acs_url,
- return_state,
- conf_data )
|
[Only for authenticators that implement get_user_from_request()]
Returns the URL to which the hub should redirect for
SSO authentication.
| acs_url
|
is the Assertion Consumer Service URL to which
the IdP should send the POST request after
authentication. This will be a URL on the hub. |
| return_state
|
is a URL-encoded string containing information
the hub uses to redirect the user back to the right
page after authentication is done. |
| conf_data
|
is a tuple containing any information gathered
from the form fields of the HTML fragement you
designed in Step 2.
When the IdP sends its response to the hub, this data
must be sent inside a POST field named RelayState. |
|
| Optional methods for
AuthCl |
|
get_conf_html(
|
Returns the HTML-format configuration fragment you designed
in Step 2. This fragment will be
displayed as part of the Form for Adding a
New Service when this authenticator type is selected.
If this method is not defined, no HTML fragment will
be associated with the authenticator.
| conf_data
|
is a dictionary containing the most recently
obtained configuration data for the service. You
can use this to highlight submitted data elements
that have failed validation.
- If the data obtained for service
configuration/reconfiguration has failed
validation, conf_data is the same
dictionary that was passed to the failed validate()
call.
- Otherwise, if this is a new service,
conf_data is None.
- Otherwise (that is, an existing service is
being edited), conf_data contains the
saved configuration data for the service.
(CodeSonar will automatically populate form fields
with the current configuration data: get_conf_html() does not need
to provide this functionality.)
|
|
get_notes(
- self,
- hub_url,
- acs_url,
- conf_data )
|
Returns the HTML-format installed
authenticator fragment you designed in Step 2. This fragment will be displayed in
the corresponding row of the table of
current services for each authentication service of
this type.
If this method is not defined, no HTML fragment will
be displayed.
| hub_url
|
The base URL for the hub.
For SSO-based authenticators, the SSO IdP will
generally need to be configured to recognize this as
the Entity ID for a permissible source of
requests. In this case, include the value of
hub_url in the returned HTML fragment, perhaps
with some IdP configuration instructions. |
| acs_url
|
The hub Assertion Consumer Service URL
associated with this service.
For SSO-based authenticators, the SSO IdP will
generally need to be configured to use this URL to
POST information to the hub. In this case, include
the value of acs_url in the returned HTML
fragment, perhaps with some IdP configuration
instructions. |
|
|
validate(
|
Verifies that the data obtained through the plug-in's
HTML fragment is valid with respect to the needs of the
authentication mechanism.
| conf_data
|
is a dictionary containing any information
gathered from the form fields of the HTML fragment
you designed in Step 2. |
On successful validation, validate(cdata)may return either a
dictionary or nothing. If a dictionary is returned, it
will replace the original information tuple in any
subsequent call to get_user().
validate(cdata)should
raise an AuthException
if the contents of cdata
are not valid data with respect to the needs of the
authentication mechanism.
|
|