There are many Services in Fedora. Many of these have an interface that we can query and get back information as JSON data. There is documentation here about both the services and the client modules that can access them.
FAS is the Fedora Account System. It holds the account data for all of our contributors.
An object for querying the Fedora Account System.
The Account System object provides a python API for talking to the Fedora Account System. It abstracts the http requests, cookie handling, and other details so you can concentrate on the methods that are important to your program.
Warning
If your code is trying to use the AccountSystem object to connect to fas for multiple users you probably want to use FasProxyClient instead. If your code is trying to reuse a single instance of AccountSystem for multiple users you definitely want to use FasProxyClient instead. Using AccountSystem in these cases may result in a user being logged in as a different user. (This may be the case even if you instantiate a new AccountSystem object for each user if :attr:cache_session: is True since that creates a file on the file system that can end up loading session credentials for the wrong person.
Changed in version 0.3.26: Added gravatar_url() that returns a url to a gravatar for a user.
Changed in version 0.3.33: Renamed gravatar_url() to avatar_url().
Returns a URL to an avatar for a given username.
Avatars are drawn from third party services.
Parameters: |
|
---|---|
Raises ValueError: | |
if the size parameter is not allowed or if the service is not one of ‘libravatar’ or ‘gravatar’ |
|
Return type: | str |
Returns: | url of a avatar for the user |
If that user has no avatar entry, instruct the remote service to redirect us to the Fedora logo.
If that user has no email attribute, then make a fake request to the third party service.
New in version 0.3.26.
Creates a FAS group.
Parameters: |
|
---|---|
Return type: | munch.Munch |
Returns: | A Munch containing information about the group that was created. |
New in version 0.3.29.
Return the config entry for the key values.
Parameters: |
|
---|---|
Raises AppError: | |
if the server returns an exception |
|
Returns: | The unicode string that describes the value. If no entry matched the username, application, and attribute then None is returned. |
Return the config entries that match the keys and the pattern.
Note: authentication on the server will prevent anyone but the user or a fas admin from viewing or changing their configs.
Parameters: |
|
---|---|
Raises AppError: | |
if the server returns an exception |
|
Returns: | A dict mapping attribute to value. |
Deprecated - Use avatar_url.
New in version 0.3.26.
Returns a group object based on its id
Returns a group object based on its name
Return administrators/sponsors/users and group type for all groups
Parameters: | force_refresh – If true, the returned data will be queried from the database, as opposed to memcached. |
---|---|
Raises AppError: | |
if the query failed on the server | |
Returns: | A dict mapping group names to the group type and the user IDs of the administrator, sponsors, and users of the group. |
New in version 0.3.8.
Return a list of people approved for a group.
This method returns a list of people who are in the requested group. The people are all approved in the group. Unapproved people are not shown. The format of data is:
\[{'username': 'person1', 'role_type': 'user'},
\{'username': 'person2', 'role_type': 'sponsor'}]
role_type can be one of ‘user’, ‘sponsor’, or ‘administrator’.
New in version 0.3.2.
Changed in version 0.3.21: Return a Bunch instead of a DictContainer
If this attribute is set to True, do not check server certificates against their CA’s. This means that man-in-the-middle attacks are possible. You might turn this option on for testing against a local version of a server with a self-signed certificate but it should be off in production.
Return a list of persons for the given groupname.
Parameters: | groupname – Name of the group to look up |
---|---|
Returns: | A list of person objects from the group. If the group contains no entries, then an empty list is returned. |
Deprecated Use people_by_key() instead.
Returns a dict relating user IDs to human_name, email, username, and bugzilla email
Changed in version 0.3.21: Return a Bunch instead of a DictContainer
Return a dict of people
For example:
>>> ret_val = FASCLIENT.people_by_key(
... key='email', search='toshio*', fields=['id'])
>>> ret_val.keys()
a.badger@[...].com
a.badger+test1@[...].com
a.badger+test2@[...].com
>>> ret_val.values()
100068
102023
102434
Parameters: |
|
---|---|
Returns: | a dict relating the key value to the fields. |
Changed in version 0.3.21: Return a Bunch instead of a DictContainer
Changed in version 0.3.26: Fixed to return a list with both people who have signed the CLA and have not
Returns a list of dicts representing database rows
Parameters: |
|
---|---|
Raises AppError: | |
if the query failed on the server (most likely because the server was given a bad query) |
|
Returns: | A list of dicts representing database rows (the keys of the dict are the columns requested) |
New in version 0.3.12.1.
Returns a person object based on its id
Returns a person object based on its username
Set a config entry in FAS for the user.
Note: authentication on the server will prevent anyone but the user or a fas admin from viewing or changing their configs.
Parameters: |
|
---|---|
Raises AppError: | |
if the server returns an exception |
Return user data for all users in FAS
Note: If the user is not authorized to see password hashes, ‘*’ is returned for the hash.
Raises AppError: | |
---|---|
if the query failed on the server | |
Returns: | A dict mapping user IDs to a username, password hash, SSH public key, email address, and status. |
New in version 0.3.8.
Generate a cert for a user
Returns a dict relating user IDs to usernames
Return whether the username and password pair are valid.
Parameters: |
|
---|---|
Returns: | True if the username/password are valid. False otherwise. |
It is not safe to use a single instance of the AccountSystem object in multiple threads. This is because instance variables are used to hold some connection-specific information (for instance, the user who is logging in). For this reason, we also provide the fedora.client.FasProxyClient object.
This is especially handy when writing authn and authz adaptors that talk to fas from a multithreaded webserver.
A threadsafe client to the Fedora Account System.
Retrieve information about a logged in user.
Parameters: | auth_params – Auth information for a particular user. For instance, this can be a username/password pair or a session_id. Refer to fedora.client.proxyclient.ProxyClient.send_request() for all the legal values for this. |
---|---|
Returns: | a tuple of session_id and information about the user. |
Raises AuthError: | |
if the auth_params do not give access |
Retrieve a list of groups
Parameters: | auth_params – Auth information for a particular user. For instance, this can be a username/password pair or a session_id. Refer to fedora.client.proxyclient.ProxyClient.send_request() for all the legal values for this. | ||||
---|---|---|---|---|---|
Returns: | a tuple of session_id and information about groups. The
groups information is in two fields:
|
||||
Raises AuthError: | |||||
if the auth_params do not give access |
Login to the Account System
Parameters: |
|
---|---|
Returns: | a tuple of the session id FAS has associated with the user and the user’s account information. This is similar to what is returned by fedora.client.proxyclient.ProxyClient.get_user_info() |
Raises AuthError: | |
if the username and password do not work |
Logout of the Account System
Parameters: | session_id – a FAS session_id to remove from FAS |
---|
Retrieve information about a particular person
Parameters: | auth_params – Auth information for a particular user. For instance, this can be a username/password pair or a session_id. Refer to fedora.client.proxyclient.ProxyClient.send_request() for all the legal values for this. |
---|---|
Returns: | a tuple of session_id and information about the user. |
Raises: |
|
Try to refresh a session_id to prevent it from timing out
Parameters: | session_id – FAS session_id to refresh |
---|---|
Returns: | session_id that FAS has set now |
Return whether the username and password pair are valid.
Parameters: |
|
---|---|
Returns: | True if the username/password are valid. False otherwise. |
Verify that a session is active.
Parameters: | session_id – session_id to verify is currently associated with a logged in user |
---|---|
Returns: | True if the session_id is valid. False otherwise. |
Bodhi is used to push updates from the build system to the download repositories. It lets packagers send packages to the testing repository or to the update repository.
pythyon-fedora currently supports both the old Bodhi1 interface and the new Bodhi2 interface. By using fedora.client.BodhiCLient, the correct one should be returned to you depending on what is running live on Fedora Infrastructure servers.