<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Divina Potentia - Home</title>
  <id>tag:divinapotentia.com,2008:mephisto/</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  <link href="http://divinapotentia.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://divinapotentia.com/" rel="alternate" type="text/html"/>
  <updated>2008-05-12T09:19:28Z</updated>
  <entry xml:base="http://divinapotentia.com/">
    <author>
      <name>juanjo</name>
    </author>
    <id>tag:divinapotentia.com,2008-05-12:5</id>
    <published>2008-05-12T09:12:00Z</published>
    <updated>2008-05-12T09:19:28Z</updated>
    <category term="acts_as_state_machine"/>
    <category term="rails"/>
    <category term="restful_authentication"/>
    <link href="http://divinapotentia.com/12/5/2008/uninitialized-constant-rails-plugin-railsstudio" rel="alternate" type="text/html"/>
    <title>uninitialized constant Rails::Plugin::RailsStudio</title>
<content type="html">
            &lt;p&gt;Intentando hacer funcionar acts_as_state_machine con restful_authentication me he encontrado con un error al intentar hacer rake db:migrate :&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;&lt;span class=&quot;caps&quot;&gt;ERROR&lt;/span&gt;:&lt;/b&gt;&lt;/p&gt;


	&lt;p&gt;uninitialized constant Rails::Plugin::RailsStudio&lt;/p&gt;


	&lt;p&gt;Este error se debe a que el enlace puesto en &lt;a href=&quot;http://agilewebdevelopment.com/plugins/acts_as_state_machine&quot;&gt;http://agilewebdevelopment.com/plugins/acts_as_state_machine&lt;/a&gt; para descargar el plugin no es correcto.&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;&lt;span class=&quot;caps&quot;&gt;SOLUCI&lt;/span&gt;ÓN:&lt;/b&gt;&lt;/p&gt;


	&lt;p&gt;Buscando por ahí, me he encontrado un post en el foro de Aptana que nos dice que utilicemos este otro enlace para solucionar el problema:
&lt;a href=&quot;http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk/&quot;&gt;http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk/&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://divinapotentia.com/">
    <author>
      <name>juanjo</name>
    </author>
    <id>tag:divinapotentia.com,2008-04-09:4</id>
    <published>2008-04-09T00:29:00Z</published>
    <updated>2008-04-09T00:49:53Z</updated>
    <category term="Seguridad"/>
    <category term="owasp"/>
    <category term="security"/>
    <category term="testing"/>
    <link href="http://divinapotentia.com/9/4/2008/webscarab" rel="alternate" type="text/html"/>
    <title>WebScarab, un framework para el an&#225;lisis de aplicaciones web</title>
<content type="html">
            &lt;p&gt;Navegando por la web de &lt;a href=&quot;http://www.owasp.org&quot;&gt;&lt;span class=&quot;caps&quot;&gt;OWASP&lt;/span&gt;&lt;/a&gt; me encontré con esta joyita, &lt;b&gt;WebScarab&lt;/b&gt;. La herramienta en cuestión es un framework para análisis de aplicaciones web bastante completo. Trabaja con &lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt; y &lt;span class=&quot;caps&quot;&gt;HTTPS&lt;/span&gt;, y podemos hacer cosas tan útiles como actuar de proxy, ver las requests y responses de la página&#8230; revisarlas y modificarlas para poder mandárselas al servidor, antes que lleguen al cliente. Muy útil.&lt;/p&gt;


	&lt;p&gt;Está implementada en Java, por lo que no tendremos ningún problema en ejecutarla en MS Windows, &lt;span class=&quot;caps&quot;&gt;GNU&lt;/span&gt;/Linux o Apple MacOS X.
Actualmente la gente de &lt;span class=&quot;caps&quot;&gt;OWASP&lt;/span&gt; está trabajando en la reescritura de WebScarab, llamándose esta nueva versión &lt;b&gt;WebScarab NG&lt;/b&gt;. Por lo que comentan la nueva versión solo aportará un entorno más agradable: i18n, teclas rápidas&#8230; Yo aún no lo he probado, pero estaré al tanto&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Podemos descargar la herramienta desde aquí :&lt;a href=&quot;http://www.owasp.org/index.php/OWASP_WebScarab_Project&quot;&gt;WebScarab&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Proyecto &lt;a href=&quot;http://www.owasp.org/index.php/OWASP_WebScarab_NG_Project&quot;&gt;WebScarab NG&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;a href=&quot;http://www.owasp.org/images/3/31/WebScarab_after_browsing.png&quot;&gt;&lt;img src=&quot;http://divinapotentia.com/assets/2008/4/9/WebScarab_after_browsing.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://divinapotentia.com/">
    <author>
      <name>juanjo</name>
    </author>
    <id>tag:divinapotentia.com,2008-04-07:2</id>
    <published>2008-04-07T14:01:00Z</published>
    <updated>2008-04-09T00:27:32Z</updated>
    <category term="Ruby On Rails"/>
    <category term="owasp"/>
    <category term="rubyonrails"/>
    <category term="security"/>
    <link href="http://divinapotentia.com/7/4/2008/owasp-y-ruby-on-rails-web-application-security-put-into-practice" rel="alternate" type="text/html"/>
    <title>OWASP y Ruby On Rails :: Web Application Security Put Into Practice</title>
<content type="html">
            &lt;p&gt;La semana pasada en la &lt;span class=&quot;caps&quot;&gt;FS2008&lt;/span&gt; de RedIris tomamos contacto con &lt;a href=&quot;http://www.owasp.org/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;OWASP&lt;/span&gt;&lt;/a&gt;. Es una comunidad centrada en la seguridad de software de aplicación&#8230;&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;pero&#8230; ¿qué o quienes son &lt;span class=&quot;caps&quot;&gt;OWASP&lt;/span&gt;?&lt;/b&gt;&lt;/p&gt;


	&lt;p&gt;&lt;i&gt;&#8220;The Open Web Application Security Project (OWASP) is a worldwide free and open community focused on improving the security of application software. Our mission is to make application security &#8220;visible,&#8221; so that people and organizations can make informed decisions about application security risks. Everyone is free to participate in &lt;span class=&quot;caps&quot;&gt;OWASP&lt;/span&gt; and all of our materials are available under an open source license. The &lt;span class=&quot;caps&quot;&gt;OWASP&lt;/span&gt; Foundation is a 501c3 not-for-profit charitable organization that ensures the ongoing availability and support for our work.&#8221;&lt;/i&gt;&lt;/p&gt;


	&lt;p&gt;Debido a la gran cantidad de ataques que existen actualmente, y la preocupante situación frente a las cifras de &lt;a href=&quot;http://www.sans.org/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;SANS&lt;/span&gt; Institute&lt;/a&gt;, pienso que tenemos que tomarnos un poco más en serio la seguridad.&lt;/p&gt;


	&lt;p&gt;Entre otras cosas, en esta guia se habla de cómo evitar algunos ataques conocidos:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;XSS&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;CSRF&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;Insecure Direct Object Reference&lt;/li&gt;
		&lt;li&gt;Malicious File Execution&lt;/li&gt;
		&lt;li&gt;...&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;La guía Web Application Security Put Into Practice: Ruby On Rails Security (68 páginas), podemos descargarnosla desde &lt;a href=&quot;http://www.lulu.com/items/volume_62/1412000/1412042/1/print/Owasp-rails-security.pdf&quot;&gt;aquí&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://divinapotentia.com/">
    <author>
      <name>juanjo</name>
    </author>
    <id>tag:divinapotentia.com,2008-01-20:3</id>
    <published>2008-01-20T14:07:00Z</published>
    <updated>2008-04-07T14:14:38Z</updated>
    <category term="Ruby On Rails"/>
    <category term="activeldap"/>
    <category term="ldap"/>
    <category term="rubyonrails"/>
    <link href="http://divinapotentia.com/20/1/2008/autenticaci-n-con-activeldap-en-ruby-on-rails" rel="alternate" type="text/html"/>
    <title>Autenticaci&#243;n con ActiveLDAP en Ruby on Rails</title>
<content type="html">
            &lt;p&gt;Para hacer una pruebas he necesitado autenticar contra un servidor &lt;span class=&quot;caps&quot;&gt;LDAP&lt;/span&gt; con Rails, pero la verdad que tras buscar y buscar no he encontrado mucha información. Entre las cosas que he encontrado ha sido el plugin Ruby/ActiveLdap (&lt;a href=&quot;http://www.activeldap.com/&quot;&gt;http://www.activeldap.com/&lt;/a&gt;).&lt;/p&gt;


	&lt;h2&gt;¿Qué es ActiveLdap?&lt;/h2&gt;


	&lt;p&gt;&lt;i&gt;&#8220;Ruby/ActiveLdap provides an object oriented interface to &lt;span class=&quot;caps&quot;&gt;LDAP&lt;/span&gt;. This library was inspired by ActiveRecord (both the concept and the library). It maps &lt;span class=&quot;caps&quot;&gt;LDAP&lt;/span&gt; entries to Ruby objects with &lt;span class=&quot;caps&quot;&gt;LDAP&lt;/span&gt; attribute accessors exposed as methods dynamically assigned based on your &lt;span class=&quot;caps&quot;&gt;LDAP&lt;/span&gt; schema and each object’s objectClasses.&#8221;&lt;/i&gt;&lt;/p&gt;


	&lt;p&gt;Es en esta página (www.activeldap.com) dónde podemos encontrar 2 minitutoriales interesantes:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.activeldap.com/index.php?topic=activeldap-on-ubuntu&quot;&gt;Installing Ruby/ActiveLdap on Ubuntu Dapper 6.06 &lt;span class=&quot;caps&quot;&gt;LTS&lt;/span&gt; or Feisty 7.04&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://www.activeldap.com/index.php?topic=sample-application&quot;&gt;A Sample Application with ActiveLDAP&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Con estas librería podemos conectar con un árbol, realizar consultas&#8230; pero no son en sí un sistema de autenticación, sino que hemos de implementarlo nosotros mismos. Para mis pruebas me he decantado por utilizar el sistema explicado en &#8216;Practical Rails Social Networking Sites (Expert&#8217;s Voice)&#8217;, aunque modificado para que autentique contra un árbol. Tengo claro que no es ni mucho menos el mejor sistema del mundo, pero bueno&#8230; para mis pruebas me sirve. Pienso que lo correcto sería modificar acts_as_authenticated y modificarlo para que funcione con este plugin.&lt;/p&gt;


	&lt;h3&gt;lib/authenticate_ldap_system:&lt;/h3&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;AuthenticateLdapSystem&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;protected&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;is_logged_in?&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;iv&quot;&gt;@logged_in_user&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;LdapUser&lt;/span&gt;.find(&lt;span class=&quot;sy&quot;&gt;:all&lt;/span&gt;,&lt;span class=&quot;sy&quot;&gt;:attribute&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;uid&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:value&lt;/span&gt; =&amp;gt; session[&lt;span class=&quot;sy&quot;&gt;:user&lt;/span&gt;]) &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; session[&lt;span class=&quot;sy&quot;&gt;:user&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;logged_in_user&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;iv&quot;&gt;@logged_in_user&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; is_logged_in?&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;logged_in_user=&lt;/span&gt;(user)&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; !user.nil?&lt;tt&gt;
&lt;/tt&gt;session[&lt;span class=&quot;sy&quot;&gt;:user&lt;/span&gt;] = user.uid&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;iv&quot;&gt;@logged_in_user&lt;/span&gt; = user&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;self&lt;/span&gt;.included(base)&lt;tt&gt;
&lt;/tt&gt;base.send &lt;span class=&quot;sy&quot;&gt;:helper_method&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:is_logged_in?&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:logged_in_user&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;login_required&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;unless&lt;/span&gt; is_logged_in?&lt;tt&gt;
&lt;/tt&gt;flash[&lt;span class=&quot;sy&quot;&gt;:error&lt;/span&gt;] = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Debe estar autenticado para realizar esta acción.&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;redirect_to &lt;span class=&quot;sy&quot;&gt;:controller&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;login&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;h3&gt;controllers/application.rb:&lt;/h3&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;ApplicationController&lt;/span&gt; &amp;lt; secret =&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;d3ae1ee162786bf4a3ad4fbcabdb4019&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;# Hacemos que las contraseñas no salgan en claro en los logs&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;filter_parameter_logging &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;# Incluimos nuestro sistema de autenticación&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;include &lt;span class=&quot;co&quot;&gt;AuthenticateLdapSystem&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;h3&gt;controllers/login_controller.rb:&lt;/h3&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;LoginController&lt;/span&gt; &amp;lt; logged_in_user =&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; LdapUser.authenticate(params[:user][:username],&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; action =&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;login&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;logout&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; request.post?&lt;tt&gt;
&lt;/tt&gt;reset_session&lt;tt&gt;
&lt;/tt&gt;flash[&lt;span class=&quot;sy&quot;&gt;:notice&lt;/span&gt;] = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Acaba de dejar la zona segura.&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;redirect_to index_url&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;h3&gt;model/ldap_user.rb:&lt;/h3&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;LdapUser&lt;/span&gt; &amp;lt; dn_attribute =&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;uid&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;sy&quot;&gt;:prefix&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ou=Usuarios&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;sy&quot;&gt;:classes&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;sy&quot;&gt;:scope&lt;/span&gt; =&amp;gt; &lt;span class=&quot;sy&quot;&gt;:one&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;belongs_to &lt;span class=&quot;sy&quot;&gt;:blog&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:class&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Blog&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:foreign_key&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;uid&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;self&lt;/span&gt;.authenticate(username, password)&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;co&quot;&gt;ActiveLdap&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;.establish_connection(&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;sy&quot;&gt;:host&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ldap.ejemplo.com&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;sy&quot;&gt;:port&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;389&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;sy&quot;&gt;:base&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;dc=ejemplo&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;sy&quot;&gt;:bind_dn&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;uid=&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;#{&lt;/span&gt;username&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;,ou=usuarios,dc=ejemplo&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;sy&quot;&gt;:password_block&lt;/span&gt; =&amp;gt; &lt;span class=&quot;co&quot;&gt;Proc&lt;/span&gt;.new { password },&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;sy&quot;&gt;:allow_anonymous&lt;/span&gt; =&amp;gt; &lt;span class=&quot;pc&quot;&gt;false&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;co&quot;&gt;LdapUser&lt;/span&gt;.find(&lt;span class=&quot;sy&quot;&gt;:first&lt;/span&gt;,&lt;span class=&quot;sy&quot;&gt;:attribute&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;uid&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:value&lt;/span&gt; =&amp;gt; username)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;co&quot;&gt;ActiveLdap&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;AuthenticationError&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;return&lt;/span&gt; null&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
          </content>  </entry>
</feed>
