auth Package¶
permissions
Module¶
-
lemur.auth.permissions.
AuthorityCreator
alias of
authority
-
lemur.auth.permissions.
AuthorityOwner
alias of
authority
-
class
lemur.auth.permissions.
AuthorityPermission
(authority_id, roles) Bases:
flask_principal.Permission
-
lemur.auth.permissions.
CertificateCreator
alias of
certificate
-
lemur.auth.permissions.
RoleUser
alias of
role
-
class
lemur.auth.permissions.
SensitiveDomainPermission
Bases:
flask_principal.Permission
-
class
lemur.auth.permissions.
UpdateCertificatePermission
(certificate_id, owner) Bases:
flask_principal.Permission
-
class
lemur.auth.permissions.
ViewKeyPermission
(certificate_id, owner) Bases:
flask_principal.Permission
-
class
lemur.auth.permissions.
ViewRoleCredentialsPermission
(role_id) Bases:
flask_principal.Permission
service
Module¶
-
class
lemur.auth.service.
AuthenticatedResource
Bases:
flask_restful.Resource
Inherited by all resources that need to be protected by authentication.
-
method_decorators
= [<function login_required at 0x7fd1fc506ed8>]
-
-
lemur.auth.service.
base64url_decode
(data)
-
lemur.auth.service.
base64url_encode
(data)
-
lemur.auth.service.
create_token
(user) Create a valid JWT for a given user, this token is then used to authenticate sessions until the token expires.
Parameters: user – Returns:
-
lemur.auth.service.
fetch_token_header
(token) Fetch the header out of the JWT token.
Parameters: token – Returns: raise jwt.DecodeError:
-
lemur.auth.service.
get_rsa_public_key
(n, e) Retrieve an RSA public key based on a module and exponent as provided by the JWKS format.
Parameters: - n –
- e –
Returns: a RSA Public Key in PEM format
-
lemur.auth.service.
login_required
(f) Validates the JWT and ensures that is has not expired.
Parameters: f – Returns:
-
lemur.auth.service.
on_identity_loaded
(sender, identity) Sets the identity of a given option, assigns additional permissions based on the role that the user is a part of.
Parameters: - sender –
- identity –
views
Module¶
-
class
lemur.auth.views.
Google
Bases:
flask_restful.Resource
-
endpoint
= 'google'
-
mediatypes
(resource_cls)
-
methods
= ['POST']
-
post
()
-
-
class
lemur.auth.views.
Login
Bases:
flask_restful.Resource
Provides an endpoint for Lemur’s basic authentication. It takes a username and password combination and returns a JWT token.
This token token is required for each API request and must be provided in the Authorization Header for the request.
Authorization:Bearer <token>
Tokens have a set expiration date. You can inspect the token expiration by base64 decoding the token and inspecting it’s contents.
Note
It is recommended that the token expiration is fairly short lived (hours not days). This will largely depend on your uses cases but. It is important to not that there is currently no build in method to revoke a users token and force re-authentication.
-
endpoint
= 'login'
-
get
()
-
mediatypes
(resource_cls)
-
methods
= ['GET', 'POST']
-
post
() -
POST
/auth/login
¶ Login with username:password
Example request:
POST /auth/login HTTP/1.1 Host: example.com Accept: application/json, text/javascript { "username": "test", "password": "test" }
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "token": "12343243243" }
Parameters: - username – username
- password – password
Status Codes: - 401 Unauthorized – invalid credentials
- 200 OK – no error
-
-
-
class
lemur.auth.views.
Ping
Bases:
flask_restful.Resource
This class serves as an example of how one might implement an SSO provider for use with Lemur. In this example we use a OpenIDConnect authentication flow, that is essentially OAuth2 underneath. If you have an OAuth2 provider you want to use Lemur there would be two steps:
- Define your own class that inherits from
flask.ext.restful.Resource
and create the HTTP methods the provider uses for it’s callbacks. - Add or change the Lemur AngularJS Configuration to point to your new provider
-
endpoint
= 'ping'
-
mediatypes
(resource_cls)
-
methods
= ['POST']
-
post
()
- Define your own class that inherits from
-
class
lemur.auth.views.
Providers
Bases:
flask_restful.Resource
-
endpoint
= 'providers'
-
get
()
-
mediatypes
(resource_cls)
-
methods
= ['GET']
-