giovedì 28 giugno 2012

openshift: come gestire la rotazione dei log

Utile post dal forum per gestire la rotazione dei log ed eventuale eliminazione/compressione:
https://openshift.redhat.com/community/forums/openshift/log-rotation-not-enabled





cd $OPENSHIFT_LOGS_DIR   
 
   find . -type f ( -name access_log-* , -name error_log-* ) -mtime +180  
   #  Add this to the above command to backup as a gzipped tarball:    | xargs tar -czvf  backup-logs-$(date +%Y%m%d).tar.gz   
   #  Add this to the above command to delete 'em:   -exec rm {} \;      or     | xargs rm)   

martedì 5 giugno 2012

openshift+jboss: RewriteValve from 80 to 443

riportato dal forum:


1. In your application, create a file called jboss-web.xml in src/main/webapp/WEB-INF/ directory with this content.
 sh$ cat  src/main/webapp/WEB-INF/jboss-web.xml   
<jboss-web>
      <security-domain>jboss-web-policy</security-domain>
       <valve>
             <class-name>org.jboss.web.rewrite.RewriteValve</class-name>
       </valve>
</jboss-web>
2. Create a rewrite.properties file in the src/main/webapp/WEB-INF/ directory with checking for http and redirecting to https.
sh$ cat src/main/webapp/WEB-INF/rewrite.properties  
RewriteCond %{HTTP:X-Forwarded-Proto} http   
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]    

links utili

sabato 19 maggio 2012

jboss7 deployment timeout

Se il server va in timeout durante il deploy, undeploya tutte le applicazioni.

per evitarlo:


 <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
            <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" deployment-timeout="6000"/>
        </subsystem>

java.lang.IllegalStateException: Parameter count exceeded allowed maximum: 512

immagina di avere una mega griglia con numero di parametri variabile ed alto...
quando viene fatto il submit e partono i valori jboss7 risponde:


java.lang.IllegalStateException: Parameter count exceeded allowed maximum: 512


https://community.jboss.org/thread/197650?_sscc=t

Add the following system property to the configuration file(eg standalone.xml).
<property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="10000"/>
grande openshift!!

domenica 29 aprile 2012

openshift: non esiste +$OPENSHIFT_APP_DIR

modificare script post_deplo!!
da $OPENSHIFT_APP_DIR/ a $OPENSHIFT_HOMEDIR/$OPENSHIFT_APP_NAME/

openshift: remove file with git

Remember this:


git rm -rf src/ pom.xml
git commit -a -m "removing default files"

domenica 15 aprile 2012

picketlink social: come creare un meccanismo di autenticazione+autorizzazione ibrido

Scenario: sito web con registrazione utenti per fornire servizi personalizzati
autenticazione + autorizzazione: come gestirle?

Tecnologia prescelta: jee6 + jboss (su openshift) + mysql

Soluzioni possibili:
 - tutto interno
 - autenticazione esterna + autorizzazione interna
 - entrambe le soluzioni insieme

Ragioniamo...
Oggi quasi tutti hanno un account su facebook o su google, perchè non utilizzare il sistema di autenticazione offerto da questi provider, gestendo internamente il processo di autorizzazione?

Nulla toglie la possibilità di registrare un utente internamente per il processo di autenticazione + autorizzazione..

Soluzione: usare due domini di sicurezza a cascata.

Indizi:
usare facebbok + google per autenticazione:
http://server.dzone.com/articles/jbossas7-making-your-web

Multiple login modules can be chained together in a stack, with each login module providing both the authentication and authorization components. This works for many use cases, but sometimes authentication and authorization are split across multiple user management stores.
http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/5/html/Security_Guide/ch12.html#sect-Password_Stacking

Abilitare l'audit del processo di autenticazione:
http://middlewaremagic.com/jboss/?p=453

Gestione dei domini in standalone.xml:

<security-domain cache-type="default" name="external_auth">
            <authentication>
                <login-module code="org.picketlink.social.auth.ExternalAuthLoginModule" flag="required">
                    <module-option name="password-stacking" value="useFirstPass">
                </module-option></login-module>
                 <login-module code="Database" flag="required">
                    <module-option name="dsJndiName" value="java:jboss/datasources/MysqlDS">
                    <module-option name="principalsQuery" value="select A.password from UserAuth as A where A.username=?">
                    <module-option name="rolesQuery" value="SELECT B.roleName,'Roles' FROM UserRole as B left join UserAuth as A on (A.id =B.userAuth_id) where A.username = ?">
                    <module-option name="password-stacking" value="useFirstPass">                   
                </module-option></module-option></module-option></module-option></login-module>
            </authentication>
        </security-domain>


Questo è solo l'inizio...