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

Spring Java Discussion :

localhost vous a redirigé à de trop nombreuses reprises.


Sujet :

Spring Java

  1. #1
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2017
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2017
    Messages : 18
    Points : 13
    Points
    13
    Par défaut localhost vous a redirigé à de trop nombreuses reprises.
    Bonjour à tous
    Je suis en train de tester le module spring-security
    j'ai essayé d'utiliser mon propre form login mais ça ne marche pas

    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
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
     
     
     
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package org.sid.security;
     
    import java.util.Collection;
    import java.util.Hashtable;
    import java.util.SortedSet;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.naming.Binding;
    import javax.naming.Context;
    import javax.naming.Name;
    import javax.naming.NameClassPair;
    import javax.naming.NameParser;
    import javax.naming.NamingEnumeration;
    import javax.naming.NamingException;
    import javax.naming.directory.Attributes;
    import javax.naming.directory.BasicAttribute;
    import javax.naming.directory.BasicAttributes;
    import javax.naming.directory.DirContext;
    import javax.naming.directory.InitialDirContext;
    import javax.naming.directory.ModificationItem;
    import javax.naming.directory.SearchControls;
    import javax.naming.directory.SearchResult;
    import org.sid.PageController;
    //import static org.sid.PageController.acc;
    import org.sid.entities.Account;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.boot.autoconfigure.security.SecurityProperties;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.core.annotation.Order;
    import org.springframework.ldap.core.ContextSource;
    import org.springframework.ldap.core.DirContextOperations;
    import org.springframework.security.authentication.AuthenticationManager;
    //import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
    ///import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
     
    //import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
     
    import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
    import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
    import org.springframework.security.config.annotation.web.builders.HttpSecurity;
    import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
    import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
    import org.springframework.security.core.Authentication;
    import org.springframework.security.core.GrantedAuthority;
    import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
    import org.springframework.security.core.context.SecurityContextHolder;
    import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
    import org.springframework.security.crypto.password.LdapShaPasswordEncoder;
    //import org.springframework.security.crypto.password.LdapShaPasswordEncoder;
    //import org.springframework.security.crypto.password.LdapShaPasswordEncoder;
    import org.springframework.security.crypto.password.PasswordEncoder;
    import org.springframework.security.ldap.userdetails.InetOrgPerson;
    import org.springframework.security.ldap.userdetails.InetOrgPersonContextMapper;
    import org.springframework.security.ldap.userdetails.UserDetailsContextMapper;
     
    /**
     *
     * @author ASUS
     */
    @Configuration 
    //@Order(SecurityProperties.BASIC_AUTH_ORDER) 
    public class SecurityConfig extends WebSecurityConfigurerAdapter{
     
     
        public static Account acc=new Account();
     
             @Value("${ldap.urls}")
    	private String ldapUrls;
     
    	@Value("${ldap.base.dn}")
    	private String ldapBaseDn;
     
    	@Value("${ldap.user.dn.pattern}")
    	private String ldapUserDnPattern;
     
    	@Value("${ldap.enabled}")
    	private String ldapEnabled;
     
     
     
            @Bean
    public AuthenticationManager authenticationManagerBean() throws Exception {
        // ALTHOUGH THIS SEEMS LIKE USELESS CODE,
        // ITS REQUIRED TO PREVENT SPRING BOOT AUTO-CONFIGURATION
        return super.authenticationManagerBean();
    }
     
     
     
            //@Override
    	protected void configure(HttpSecurity http) throws Exception {
            http
            	.authorizeRequests()
    				.anyRequest().authenticated()
    				.and()
    			.formLogin().loginPage("/login").and().httpBasic().disable();
     
     
     
     
     
    	}
     
        @Bean
    public InetOrgPersonContextMapper userContextMapper() {
        return new InetOrgPersonContextMapper();
    }
     
           @Override
    	protected void configure(AuthenticationManagerBuilder auth) throws Exception {
     
                 GrantedAuthoritiesMapper grantedAuthoritiesMapper = null;
     
     
    			auth
    				.ldapAuthentication().userDnPatterns("uid={0},ou=users").authoritiesMapper(grantedAuthoritiesMapper)
     
    				.contextSource()
    					.url("ldap://localhost:10389/" + ldapBaseDn)
     
     
    					.and()
     
                                    .passwordCompare()
                        .passwordAttribute("userPassword")
                                    .and()
                                    .passwordEncoder(new LdapShaPasswordEncoder());
     
     
     
     
     
     
     
     
     
     
     
     
     
        }
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    }
    Contoller:
    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
     
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package org.sid.security;
     
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
     
    /**
     *
     * @author ASUS
     */
    @Controller
    public class SecurityController {
     
        @RequestMapping(value="/login")
        public String login(){
            return"login";
        }
     
        @RequestMapping(value="/")
        public String home(){
            return"redirect:/dec";
        }
     
    }
    formulaire:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    <form class="login-form" th:action="@{/login}" method="post">
                                                <div th:if="${param.error}" class="text-danger">
                                                Username ou mot de passe incorrects 
                                                </div>
                                                <input type="hidden"
               name="${_csrf.parameterName}"
               value="${_csrf.token}"/>
                        				<input type="text" class="input" id="user_login" name="username" autocomplete="off" placeholder="Login"/>
                        				<input type="password" class="input" id="user_pass" name="password" autocomplete="off" placeholder="Mot de passe"/>
                        				<input type="checkbox" class="checkbox"  id="remember_me"/>
                        				<label for="remember_me">Maintenir la connexion</label>
                        				<input type="submit" class="button" value="Login">
                        			</form>

  2. #2
    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
    tu as indiqué que toutes les requêtes doivent être identifiées. Cela inclus le formulaire de login. Du coup spring security te redirige en boucle sur le login et le browser fini par abandonner.

  3. #3
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2017
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2017
    Messages : 18
    Points : 13
    Points
    13
    Par défaut
    Quelle est la solution??

    l'interface login ne s'affiche pas

  4. #4
    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
    ben le login ne dois pas faire partie des pages protégées par login. Par exemple si ma mémoire est bonne

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     .formLogin()
                .....
                .permitAll()
                .and()
                .anyRequest().authenticated()

  5. #5
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2017
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2017
    Messages : 18
    Points : 13
    Points
    13
    Par défaut
    rien ne fonctionne

Discussions similaires

  1. [IIS 7.5] vous a redirigé à de trop nombreuses reprises.
    Par scharles45 dans le forum IIS
    Réponses: 0
    Dernier message: 03/07/2017, 12h13
  2. Imbrications trop nombreuses - Mon code part trop sur la droite
    Par Sve@r dans le forum Général Python
    Réponses: 11
    Dernier message: 24/02/2008, 11h03
  3. Jointures implicites générées trop nombreuses
    Par killergege dans le forum Hibernate
    Réponses: 3
    Dernier message: 01/08/2007, 15h19
  4. [VB 6.0 + sql server] pb insertion de lignes trop nombreuses
    Par flores dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 30/10/2006, 16h29
  5. Réponses: 4
    Dernier message: 18/11/2004, 13h26

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