IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Tomcat et TomEE Java Discussion :

Servlet j_security_check et Captcha dans le même form


Sujet :

Tomcat et TomEE Java

  1. #1
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 705
    Points : 934
    Points
    934
    Par défaut Servlet j_security_check et Captcha dans le même form
    Bonjour,

    J'ai actuellement une autentification j_security_check, je souhaite la renforcer par une image dynamique. j'ai deja une appli struts2 qui fait la captcha, mais je souhaite faire cela dans le meme formulaire.
    Ou est situe la servlet tomcat de securite, et puis je l'extend ?
    Ou arlors dans mon action struts2 apres la verification de mon image, faire appel a la servlet de "j_security_check" sans ressaisi des parametres ?

    J'ai essaye un "http://localhost:8080/EM/j_security_check?j_username=" + j_username + "&j_password=" + j_password pour voir si cela passait en direct ,mais sans succes


    Merci d'avance
    Phil

  2. #2
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 705
    Points : 934
    Points
    934
    Par défaut
    Bonjour

    le paramètre "j_uri" existe t il en tomcat7 ?
    J'ai bien une JSP avec le login, le mot de passe et l'image de ma captcha, mais le "post" va etre dirigé vers j_check_security", donc dans le cas d'un succès je souhaiterais être dirigé vers l'action qui test mon image avec la chaine saisie.

    Merci d'avance
    Phil

  3. #3
    Expert confirmé
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 274
    Points : 4 141
    Points
    4 141
    Par défaut
    Tu appelles en premier l'action qui vérifie ton captcha, en envoyant également les login et password.
    Puis si le test est ok, tu rediriges vers l'action j_security_check en POST avec les login et password précédemment récupérés.

  4. #4
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 705
    Points : 934
    Points
    934
    Par défaut
    Ok je vais voir comment faire la redirection vers la captcha, j'ai juste un doute sur le fait que l'on puisse rediriger du struts2 ver le j_security_check)

    je pense a cela non testé
    la JSP

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
     
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <html>
    <head>
    <title>Capcha Aut Validation</title>
    <style>
    .errorMessage {
    color: red;
    font-size: 0.8em;
    } 
     
    .label {
    color:#000000;
    }
    </style>
    </head>
    <body>
    	<table>
    		<tr>
    		<td>
    			<h1>Captcha Validation</h1>
    		<s:form action="doCaptchaAut" method="POST">
    			<s:actionerror /> 
    			<!-- voir le web.xml -->
    			<img src="Captcha2.jpg" border="0">
    			<s:textfield label="Code" name="j_captcha_response" size="20" maxlength="10"/>
    			<s:textfield label="Login" name="j_username" size="20" maxlength="10"/>
    			<s:textfield label="Mot de passe" name="j_password" />
    			<s:submit value="Verify" align="center" />
    			</s:form>
    		</td>
    		</tr>
    	</table>
    </body>
    </html>
    le struts.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
     
    <result name="success" type="redirect-action">
            <param name="actionName">j_security_check</param>
            <param name="j_username">${j_username}</param>
    	    <param name="j_password">${j_password}</param>
        </result>

  5. #5
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 705
    Points : 934
    Points
    934
    Par défaut
    Bonjour

    Je verifie dabbord l'image "captcha" puis tente une redirection vers "j_security_check", mais
    La redirection ne fonctionne pas !
    There is no Action mapped for namespace [/] and action name [j_security_check] associated with context path
    (je crois que ce doit etre un POST et non un GET la redirection)

    la JSP dans le context /v0captcha2
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
    <form method="POST" action="doCaptchaAut">
    <table>
    <tr>
    <td><img src="Captcha2.jpg" border="0"></td>
    <td><input type="text" name="j_captcha_response"></td>
    </tr>
    <tr>
    <td>Login :</td>
    <td><input type="text" name="j_username"></td>
    </tr>
    <tr>
    <td>Mot de passe :</td>
    <td><input type="password" name="j_password"></td>
    </tr>
    <tr>
    <td><input type="submit" value="Entrer !"></td>
    <td><input type="reset" value="Annuler"></td>
    </tr>
    </table>
    </form>
    struts.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    <action name="doCaptchaAut" class="captcha2.action.CaptchaAction">
    <result name="error">captcha3c.jsp</result>
    <result name="success" type="redirectAction">
            <param name="actionName">j_security_check</param>
            <param name="j_username">${j_username}</param>
        	<param name="j_password">${j_password}</param>
        </result>
     
    </action>
    Message d'erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
     
    There is no Action mapped for namespace [/] and action name [j_security_check] associated with context path [/v0captcha2]. - [unknown location] 
        com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
        org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
        org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
        com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
        org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:534)
        org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
        org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
        org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
        org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
        org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
        org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
        org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
        java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        java.lang.Thread.run(Thread.java:662)
    meme probleme dans le cas d'un chaining d'action au lieu de la redirection
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
     
     
      <action name="doCaptchaAut2" class="captcha2.action.CaptchaAction">             
      <result name="success" type="chain">j_security_check</result>
      </action>   
     
     
    <div id="stacktraces">
    <hr />
    <h3>Stacktraces</h3>
    <div class="stacktrace" style="padding-left: 0em">
        <strong>There is no Action mapped for namespace [/] and action name [j_security_check] associated with context path [/v0captcha2]. - [unknown location]</strong>
        <div>
        <pre>
        com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
        org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
        org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
        com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
        com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
        com.opensymphony.xwork2.ActionChainResult.execute(ActionChainResult.java:232)
        com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:367)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:271)
        org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
        com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
        org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
        com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
        com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
        com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
        com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
        org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
        org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:544)
        org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
        org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        org.apache.catalina.core.ApplicationFilterChain
    Une idee ?
    Merci d'avance
    Phil

  6. #6
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Citation Envoyé par fr1man Voir le message
    Tu appelles en premier l'action qui vérifie ton captcha, en envoyant également les login et password.
    Puis si le test est ok, tu rediriges vers l'action j_security_check en POST avec les login et password précédemment récupérés.
    PAN!

    On ne redirige jamais vers le j_security_check ou vers le formulaire de login, c'est explicitement refusé par les container. Dans le but d'empêcher différentes formes de fishing ou de cookies injection.

    De même il n'y a pas de mécanisme que je connaisse qui permettent facilement d'être notifié qu'un utilisateur viens de se loggué (histoire de vérifier le captcha).

    Tu peux essayer de jouer avec des filter, mais bonne chance....

    Quel est le but du captch sur le form login dans l'histoire?

  7. #7
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 705
    Points : 934
    Points
    934
    Par défaut
    Bonjour,

    Le but du captcha est de rajouter une image de secutité en plus du login/mot de passe.

  8. #8
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Je vais dire ça autrement (parce que là tu m'a définis le captcha), pourquoi as-tu besoin de cette image de sécurité?

    Si la personne s'est faite voler son mot de passe, le voleur est très bien capable de résoudre la captcha. Le but du captcha et d'empêcher l'accès par des bots. Mais on vois mal des bot arriver à accéder sans mot de passe.

    Et si le but est d'empêcher le brute force à travers le formulaire.... C'est le boulot du realm de verouiller le compte après N mots de passe infructueux.

    Si ce que tu cherche c'estde gérer ta sécurité toi même en faisant fi de comment le conteneur gère déjà cette sécurité -> Ben tu retire les règle de sécurité du web.xml est tufais tout à la main dans ton code / avec des filtres, etc.

  9. #9
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 705
    Points : 934
    Points
    934
    Par défaut
    Bonjour,

    Le but est effectivement de lutter contre les BotNet, je ne savais pas que l'on pouvait mettre un nombre Maxi de tentatives à ce niveau la dans tomcat7, je vais chercher.


    a priori je dois rajouter des parametres dans mon server.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    <!--      <Realm className="org.apache.catalina.realm.LockOutRealm"> -->
    <Realm className="org.apache.catalina.realm.LockOutRealm" failureCount="3" lockOutTime="900" cacheSize="1000" cacheRemovalWarningTime="7200"> 
     
    cela changera 3 au lieu de 5
    http://tomcat.apache.org/tomcat-7.0-doc/config/realm.html
    A+
    Phil

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. plusieurs stringgrid dans la même Form
    Par jyvesb dans le forum Composants VCL
    Réponses: 2
    Dernier message: 14/03/2013, 11h41
  2. [2.x] [Symfony2]Problème Ajout de deux entités dans un même form
    Par the ing dans le forum Symfony
    Réponses: 1
    Dernier message: 14/12/2012, 17h48
  3. Décaler un fieldset par rapport à un autre dans un même form
    Par madina dans le forum Mise en page CSS
    Réponses: 4
    Dernier message: 23/08/2011, 11h59
  4. Chargement d'une page dans la même form
    Par Mistraldor dans le forum Débuter
    Réponses: 3
    Dernier message: 21/06/2011, 11h22
  5. [C#] [débutant] plusieurs panels dans la même form
    Par fsutter dans le forum Windows Forms
    Réponses: 2
    Dernier message: 11/05/2007, 17h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo