Coder Social home page Coder Social logo

pablovaldivia / embed-pentaho-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fernandommota/embed-pentaho-server

1.0 1.0 0.0 28 KB

A project to embed the Pentaho BA server using a token authentication.

License: Creative Commons Zero v1.0 Universal

Java 90.13% JavaScript 7.43% HTML 2.43%

embed-pentaho-server's Introduction

Embed Pentaho Server Sample

This project it's a sample of how embed the Pentaho server with a 3rd Web APP using a TOKEN hash.

  • Video tutorial [pt_BR]

Video tutorial [pt_BR]

References:

Credits

Original code by Francisco Gregorio:

Flow Authentication

  1. Authentication filter by token (EmbedLoginFilter)

  2. Authentication Provider validating the token parameter by API rest (EmbedAuthenticationProvider)

  3. APP-API (EmbedRestTemplate)
    3.1. Search the user logged (UserDetails) by login (EmbedUserDetailService)

Build and Installation

Build the Filter

mvn clean 
mvn compile
mvn install

After the build, copy the /target/embed-pentaho-1.0.jar file to pentaho-server/tomcat/webapps/pentaho/WEB-INF/lib/

Pentaho Server XML Injection

Inside folder pentaho-server/pentaho-solutions/system

Create a new file as applicationContext-spring-security-embed.xml and copy the following code to inject the <bean> calls.

applicationContext-spring-security-embed.xml
  • EmbedRestTemplate
  • EmbedAuthenticationProvider
  • EmbedUserDetailService
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:pen="http://www.pentaho.com/schema/pentaho-system"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
       http://www.pentaho.com/schema/pentaho-system http://www.pentaho.com/schema/pentaho-system.xsd" default-lazy-init="true">

	<bean id="embedRestTemplate"
		class="br.com.bovbi.embed.rest.EmbedRestTemplate">
   		<constructor-arg index="0" value="http://localhost:3000"/> 
      <constructor-arg index="1" value=""/>
	</bean>

	<bean id="embedAuthenticationProvider"
		class="br.com.bovbi.embed.authentication.EmbedAuthenticationProvider">
	    <constructor-arg>
	      <ref bean="embedRestTemplate"/>
	    </constructor-arg>		
		<pen:publish as-type="org.springframework.security.authentication.AuthenticationProvider">
	      <pen:attributes>
	        <pen:attr key="providerName" value="embed"/>
	      </pen:attributes>
	    </pen:publish>
	</bean>


	<bean id="embedUserDetailsService" class="br.com.bovbi.embed.service.EmbedUserDetailService">
		<pen:publish as-type="INTERFACES">
	      <pen:attributes>
	        <pen:attr key="providerName" value="embed"/>
	      </pen:attributes>
	    </pen:publish>
	</bean>
</beans>

Inject the new file in the ending of pentaho-spring-beans.xml to be imported.

  <import resource="applicationContext-spring-security-embed.xml" />

To inject the Login Filter, edit the file applicationContext-spring-security.xml

First add a <bean> tag containing:

  <bean id="embedLoginFilter" class="br.com.bovbi.embed.filter.EmbedLoginFilter">
    <constructor-arg ref="authenticationManager" />
    <property name="authenticationSuccessHandler">
      <bean class="br.com.bovbi.embed.authenticated.EmbedAuthenticationSuccessHandler">
        <property name="targetUrlParameter" value="/Home" />
      </bean>
    </property>
  </bean>
  • It's worth noting the presence of the property targetUrlParameter pointing the URL to be redirected after successful login.

Add the embedLoginFilter bean inside the filter chain locate in the filterChainProxy bean definition

  <bean id="filterChainProxy" class="org.springframework.security.web.FilterChainProxy">
    <constructor-arg>
      <util:list>
        <sec:filter-chain
             ...

In the filter chain with pattern="/**" add embedLoginFilter

  • Attention to the position, because it is possible to have filters that alter the flow of the request!
  • Add the embedLoginFilter before the filterInvocationInterceptor
     <sec:filter-chain
                    pattern="/**" 
                    filters="..., embedLoginFilter, filterInvocationInterceptor" />

After injecting embedLoginFilter into the filter filterChainProxy, change the injection of ProviderManager to add EmbedAuthenticationProvider to the list of providers.

  • Locate the authenticationManager bean definition
  <bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">
    <constructor-arg>
      <util:list>
        <pen:bean class="org.springframework.security.authentication.AuthenticationProvider"/>
        <ref bean="anonymousAuthenticationProvider" /> 
         ...

In the list being injected into the constructor, <constructor-arg>, add the bean AuthenticationProvider from embed in the first position

  • It should look like this
  <bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">
    <constructor-arg>
      <util:list>
        <pen:bean class="org.springframework.security.authentication.AuthenticationProvider">
          <pen:attributes>
            <pen:attr key="providerName" value="embed"/>
          </pen:attributes>
        </pen:bean>
        <pen:bean class="org.springframework.security.authentication.AuthenticationProvider"/>
        <ref bean="anonymousAuthenticationProvider" /> 
      </util:list>
      ...

Inside the file pentahoObjects.spring.xml locate the UserDetailsService bean definition

  <bean id="UserDetailsService" class="org.pentaho.platform.plugin.services.security.userrole.ChainedUserDetailsService">
    <constructor-arg>
      <list>
        <ref bean="activeUserDetailsService"/>
        <ref bean="systemUserDetailsService"/>
      </list>
    </constructor-arg>
  </bean>

Add embedUserDetailsService to the list of pentaho services

  • It should look like this
  <bean id="UserDetailsService" class="org.pentaho.platform.plugin.services.security.userrole.ChainedUserDetailsService">
    <constructor-arg>
      <list>
        <ref bean="activeUserDetailsService"/>
        <ref bean="embedUserDetailsService"/>
        <ref bean="systemUserDetailsService"/>
      </list>
    </constructor-arg>
  </bean>

Restart the server and monitor the pentaho log file

tail -n 300 -f tomcat/logs/catalina.out 

Wait for the follow messages to be sure that is all right!

br.com.bovbi.embed.rest.EmbedRestTemplate - on
br.com.bovbi.embed.authentication.EmbedAuthenticationProvider - on
br.com.bovbi.embed.service.EmbedUserDetailService - on
br.com.bovbi.embed.filter.EmbedLoginFilter - on

Access the URL:

embed-pentaho-server's People

Contributors

fernandommota avatar

Stargazers

Pablo Alexis Valdivia Muñoz avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.