View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

Authentication

Contents

Introduction

In context of Openbravo Authentication is the act verifying a Users' identity. This can be done by asking for Username & Password and verify it against the built-in AD_User table or any other mechanism.

The process of Authorization which is to determine which actions (like opening a specific window, or launching a process) a user then is allowed to do is a separate topic and not scope of this article.

How authentication works in Openbravo ERP

When a user wants to gain access to an Openbravo ERP resource. Openbravo ERP asks to the authentication manager the application User Id of the user that request access to the Openbravo ERP resource. If the user has not been authenticated before the authentication provider has the responsibility of authenticating this user.

The following describes the flow of events happening when using the DefaultAuthenticationManager:

Note that this only described the flow of events when using the DefaultAuthenticationManager. Any other implementation may implement this different by i.e. not using the standard Openbravo Login-page at all or using another mechanism to mark the HTTP-Session as authenticated.

How to configure the authentication manager in Openbravo ERP

The authentication manager used in Openbravo ERP is defined in the configuration file Openbravo.properties. In the property authentication.class you have to write the class name of the authentication provider that Openbravo will use for this purpose.

Openbravo includes three AuthenticationManager implementations:

Default Authentication Manager

This is the default authentication manager provided by Openbravo. It is the classic authentication method that uses the Openbravo current login page to authenticate users.

After installing Openbravo ERP you do not need to configure anything if you want to use this authentication manager that is the classic method Openbravo authenticates application users.

Autologon Authentication Manager

This is an authentication manager for demonstration purposes. It allows to every user that accesses Openbravo ERP to gain access to the application using the Openbravo user name configured for autologon without having to write neither the user name nor the password.

To configure this authentication manager in Openbravo ERP edit the Openbravo.properties file and add the property authentication.class with the value org.openbravo.authentication.basic.AutologonAuthenticationManager, add the property authentication.autologon.username with the value of the user name you want to use to login when any user accesses the application, compile the Openbravo ERP application from the command line ant compile -Dtab=xx and deploy it again.

LAM Authentication Manager (external module)

This authentication manager allows Openbravo to be connected to an LAM/CAS-server setup which provides central authentication and Single Sign-On session management.

This functionality has been separated from the main Openbravo 3 distribution and is optionally available as an module.

More details on this can be found in the wiki page of the project.

Getting Authentication Manager

Bulbgraph.png   Available from 3.0MP7

To obtain an instance of the Authentication Manager defined in the Openbravo.properties, it is possible to use the AuthenticationManager.getAuthenticationManager method.

Develop your own Authentication Manager

Bulbgraph.png   This implementation is available from 3.0MP7. From 3.0MP4 to 3.0MP6, the same is valid but web service implementation is not present in AuthenticationManager. For versions previous to 3.0MP4, AuthenticationManager was an interface, check here how it worked.

You can also develop your own Authentication manager. To do this you have to create a new java class that extends the abstract class org.openbravo.authentication.AuthenticationManager. This interface has the following methods:

 
  public void init(HttpServlet s) throws AuthenticationException;
 
  public final String authenticate(HttpServletRequest request, HttpServletResponse response)
      throws AuthenticationException, ServletException, IOException
 
  public final String webServiceAuthenticate(HttpServletRequest request)
      throws AuthenticationException
 
  public final String webServiceAuthenticate(String user, String password)
      throws AuthenticationException
 
  public final String connectorAuthenticate(HttpServletRequest request)
      throws AuthenticationException
 
  public final String connectorAuthenticate(String user, String password)
      throws AuthenticationException
 
  protected abstract String doAuthenticate(HttpServletRequest request, HttpServletResponse response)
      throws AuthenticationException, ServletException, IOException
 
  protected String doWebServiceAuthenticate(HttpServletRequest request)
 
  protected String doWebServiceAuthenticate(String user, String password)
 
  public final void logout(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException
 
  protected abstract void doLogout(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException

The method init is called after the class is instantiated. It can be used to read the configuration parameters of the authentication manager if needed.

The method authenticate is called for each single request done which requires authentication. It invokes the abstract doAuthenticate method which if this request is authenticated, must the return the userid of the authenticated user. This id must be a valid ad_user_id of a existing entry in the AD_User table.

Otherwise the method must perform the needed steps to acquire some authentication and then return null' as return-value for the function. Usually this consists of redirecting the user to some kind of Login-Page and asking for credentials. After these have been verified the authenticate method will be called again for the next request an now will succeed and return the userId as described above.

The method logout is called when the user requests to close the current session. This method invokes the abstract doLogout. The work expected to be done by the authentication manager is to invalidate the existing session and redirect the user to a page where a new login page be done.

Bulbgraph.png   Note for implementation: The authenticate method is always called with DAL adminMode being active, so code inside it does not need to manage the adminMode on its own.

Web Services and Connectors

Bulbgraph.png   All external authenticated services must make use of webServiceAuthenticate authentication. Authorized Connectors can use connectorAuthenticate.

Web Service authentication invokes webServiceAuthenticate and connectors invoke connectorAuthenticate, both of them call doWebServiceAuthenticate. This method is implemented to do standard authenitcation, it first looks whether user (l) and password (p) are sent as request parameters, if not basic authentication is performed. doWebServiceAuthenticate method can be implemented by authentication managers in case different authentication is needed.

webServiceAuthenticate and connectorAuthenticate are overloaded to accept both HttpServletRequest parameter (default one) or String, String parameters. This second one, should be used by other services where the default one is not suitable, this ones receives user and password parameters.

Retrieved from "http://wiki.openbravo.com/wiki/Authentication"

This page has been accessed 6,633 times. This page was last modified on 17 April 2013, at 13:39. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.