Skip to content

SphinxNZ/python3-openam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python 3 interface to OpenAM REST Services

Python 3.5 introduced a change to SSL cert checking in urllib. When connecting to an https OpenAM server then use python 3.5

Features and roadmap can be found in the wiki: https://github.com/Semprini/python3-openam/wiki

Code borrowed and reworked from:

This is a reworked python 3 rest interface to OpenAM using the updated API. Current OpenAM version is 12.0.0.

The tutorial for setting up an OpenAM server is here: https://backstage.forgerock.com/#!/docs/openam/12.0.0/getting-started. You can skip the Apache bit (procedure 1.2) - except for the development tools/build-essential

For REST Services documentation please see Forgerock Use OpenAM RESTful Services

To Install to site-packages:

> python setup.py install

Testing once you have a running OpenAM that you can log into from your browser:

> cd /path/to/python3-openam-<branch or master>
> python openam/tests.py http://my_openam_server:8080/openam amadmin password

Example of getting server info:

>>> from openam.context import Context
>>> context = Context('https://example.com/openam')
>>> print( context.server_info.__dict__ )
{
'referralsEnabled': 'false',
'successfulUserRegistrationDestination': 'default''zeroPageLogin': {
	'allowedWithoutReferer': True,
	'enabled': False,
	'refererWhitelist': ['']
},
'FQDN': 'example.com',
'protectedUserAttributes': [],
'secureCookie': False,
'socialImplementations': [],
'lang': 'en',
'selfRegistration': 'false',
'cookieName': 'iPlanetDirectoryPro',
'domains': ['example.com'],
'forgotPassword': 'false'
}

Example simple login user:

>>> from openam.context import Context
>>> from openam.user import User
>>> context = Context('https://example.com/openam')
>>> user = User(context, 'amadmin', 'password')
>>> user.is_valid()
True
>>> user.tokenId
'AQIC5wM2LY4SfcweNyLHBlLVnXX5h0R...
>>> user.logout()
>>> user.is_valid()
False

Example change password:

>>> from openam.context import Context
>>> from openam.user import User
>>> context = Context('https://example.com/openam')
>>> user = User(context, 'amadmin', 'password')
>>> user.is_valid()
True
>>> user.change_password('newpassword')
>>> user.logout()
>>> user = User(context, 'amadmin', 'newpassword')
>>> user.is_valid()
True

About

Python 3 interface to new OpenAM RESTful web services

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages