<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=Authentication</id>
	<title>Authentication - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=Authentication"/>
	<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=Authentication&amp;action=history"/>
	<updated>2026-04-06T18:42:29Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.infinite-erp.co.id/index.php?title=Authentication&amp;diff=2811&amp;oldid=prev</id>
		<title>Wikiadmin: Created page with &quot;== Introduction ==  In context of Openbravo ''Authentication'' is the act verifying a Users' identity. This can be done by asking for Username &amp; Password and verify it against...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=Authentication&amp;diff=2811&amp;oldid=prev"/>
		<updated>2021-12-16T05:16:10Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Introduction ==  In context of Openbravo &amp;#039;&amp;#039;Authentication&amp;#039;&amp;#039; is the act verifying a Users&amp;#039; identity. This can be done by asking for Username &amp;amp; Password and verify it against...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
In context of Openbravo ''Authentication'' is the act verifying a Users' identity. This can be done by asking for Username &amp;amp; Password and verify it against the built-in ''AD_User'' table or any other mechanism.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== How authentication works in Openbravo ERP ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The following describes the flow of events happening when using the [https://code.openbravo.com/erp/devel/pi/file/tip/src/org/openbravo/authentication/basic/DefaultAuthenticationManager.java ''DefaultAuthenticationManager'']:&lt;br /&gt;
&lt;br /&gt;
* Visit any Openbravo URL for the first time, a Cookie is send back to the browser to allow the usual creation of a HTTP-Session to allow to group the users' request together.&lt;br /&gt;
* The Authentication Manager's authenticate method is called to check if the session has been already authenticated. The DefaultAuthenticationManagers implementation checks for a special attribute in the HTTP-Session object to decide if this session is authenticated or not. As it is not yet it redirects the user to the standard Openbravo Login-Page asking for User &amp;amp; Password.&lt;br /&gt;
* When the Login Form is submitted the [https://code.openbravo.com/erp/devel/pi/file/tip/src/org/openbravo/base/secureApp/LoginHandler.java LoginHandler] class verifies those credentials against the 'AD_User'' table and if accepted sets special attribute HttpSession to mark this session as authenticated and to store the userID of the authenticated user.&lt;br /&gt;
* Then a redirect to the previously requested page is done.&lt;br /&gt;
* For this request the AuthenticationManagers' ''authenticate'' Method is called again. As now the attribute is set in the HttpSession corresponding to this request it returns the userID of the authenticated User and the request continues to be handled in the usual way.&lt;br /&gt;
* The same now happens for any following request while normally using the application.&lt;br /&gt;
* This session will be invalidated by any of the following three events:&lt;br /&gt;
** Explicit logout by the user&lt;br /&gt;
** Session-Timeout (invalidating the HttpSession)&lt;br /&gt;
** Clear Browser-Cookie by the User&lt;br /&gt;
* In that case the flow is back to the first step and the same cycle begins again.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== How to configure the authentication manager in Openbravo ERP == &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Openbravo includes three ''AuthenticationManager'' implementations:&lt;br /&gt;
&lt;br /&gt;
=== Default Authentication Manager ===&lt;br /&gt;
&lt;br /&gt;
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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== LAM Authentication Manager (external module) ===&lt;br /&gt;
&lt;br /&gt;
This authentication manager allows Openbravo to be connected to an LAM/CAS-server setup which provides central authentication and Single Sign-On session management.&lt;br /&gt;
&lt;br /&gt;
This functionality has been separated from the main Openbravo 3 distribution and is optionally available as an module.&lt;br /&gt;
&lt;br /&gt;
More details on this can be found in the wiki page of the [http://forge.openbravo.com/projects/lamauthenticationmanager project].&lt;br /&gt;
&lt;br /&gt;
== Getting Authentication Manager ==&lt;br /&gt;
{{(!) | Available from '''3.0MP7'''}}&lt;br /&gt;
&lt;br /&gt;
To obtain an instance of the Authentication Manager defined in the Openbravo.properties, it is possible to use the ''AuthenticationManager.getAuthenticationManager'' method.&lt;br /&gt;
&lt;br /&gt;
== Develop your own Authentication Manager ==&lt;br /&gt;
&lt;br /&gt;
{{ (!) | 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 [[Projects/CodeCleanupOB3#AuthenticationManager_changes|here]] how it worked. }}&lt;br /&gt;
&lt;br /&gt;
You can also develop your own Authentication manager. To do this you have to create a new java class that extends the abstract class [https://code.openbravo.com/erp/devel/pi/file/tip/src/org/openbravo/authentication/AuthenticationManager.java  org.openbravo.authentication.AuthenticationManager]. This interface has the following methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  public void init(HttpServlet s) throws AuthenticationException;&lt;br /&gt;
&lt;br /&gt;
  public final String authenticate(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;
      throws AuthenticationException, ServletException, IOException&lt;br /&gt;
&lt;br /&gt;
  public final String webServiceAuthenticate(HttpServletRequest request)&lt;br /&gt;
      throws AuthenticationException&lt;br /&gt;
&lt;br /&gt;
  public final String webServiceAuthenticate(String user, String password)&lt;br /&gt;
      throws AuthenticationException&lt;br /&gt;
&lt;br /&gt;
  public final String connectorAuthenticate(HttpServletRequest request)&lt;br /&gt;
      throws AuthenticationException&lt;br /&gt;
&lt;br /&gt;
  public final String connectorAuthenticate(String user, String password)&lt;br /&gt;
      throws AuthenticationException&lt;br /&gt;
&lt;br /&gt;
  protected abstract String doAuthenticate(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;
      throws AuthenticationException, ServletException, IOException&lt;br /&gt;
&lt;br /&gt;
  protected String doWebServiceAuthenticate(HttpServletRequest request)&lt;br /&gt;
&lt;br /&gt;
  protected String doWebServiceAuthenticate(String user, String password)&lt;br /&gt;
&lt;br /&gt;
  public final void logout(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;
      throws ServletException, IOException&lt;br /&gt;
&lt;br /&gt;
  protected abstract void doLogout(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;
      throws ServletException, IOException&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
{{(!) | Starting from [[Release_Notes/3.0PR18Q1.4|3.0PR18Q1.4]] &amp;lt;code&amp;gt;AuthenticationManager&amp;lt;/code&amp;gt;s where authentication page is served outside Openbravo code, for example from a Single Sign On service, must override &amp;lt;code&amp;gt;useExternalLoginPage&amp;lt;/code&amp;gt; method, returning &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;. }}&lt;br /&gt;
&lt;br /&gt;
{{(!) | 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.}}&lt;br /&gt;
&lt;br /&gt;
=== Web Services and Connectors ===&lt;br /&gt;
&lt;br /&gt;
{{ (!) | All external authenticated services '''must''' make use of ''webServiceAuthenticate'' authentication. Authorized ''Connectors'' can use ''connectorAuthenticate''. }}&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
''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.&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
</feed>