[JAVA] Überprüfung von [email protected]

Ich habe Spring-Session unter Bezugnahme auf diesen Artikel ausprobiert Insbesondere wollte ich XML-basierte Einstellungen anstelle von Anmerkungen vornehmen.

Dokumentation zur Frühjahrssitzung

Die offizielle Dokumentation enthält eine Beispielkonfiguration in XML.

Endgültige Bean-Konfiguration

Wenn diese Einstellung angewendet wird

    <!-- spring-Aktivieren Sie Anmerkungen in der Sitzung-->
    <context:annotation-config/>

    <!-- Spring-Aktivieren Sie die Sitzungsverwaltungsklasse auf der Sitzungsseite-->
    <bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"/>
    <!--Registrieren Sie die Redis-Client-Implementierung in Bean-->
    <bean class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory"/>

    <!--Überschreiben Sie die Standard-Cookie-Einstellungen-->
    <bean class="org.springframework.session.web.http.DefaultCookieSerializer">
        <property name="cookieName" value="JSESSIONID" />

        <!--Domainname"."Beginnen mit-->
        <property name="domainName" value=".example.com"/>

        <!--Der reguläre Ausdruck ist etwas unbestätigt-->
        <!-- <property name="domainNamePattern" value="^.+?\\.(\\w+\\.[a-z]+)$" /> -->    
    </bean>

Beziehung zwischen Cookie und IP-Adresse

Da gab es keine Domain in der Testumgebung Anfangs habe ich versucht, die Cookie-Domain nur mit der IP-Adresse abzurufen, aber es hat nicht gemäß dem Standard funktioniert.

Cookie-Standard

4.3.2  Rejecting Cookies

   To prevent possible security or privacy violations, a user agent
   rejects a cookie (shall not store its information) if any of the
   following is true:

   * The value for the Path attribute is not a prefix of the request-
     URI.

   * The value for the Domain attribute contains no embedded dots or
     does not start with a dot.

   * The value for the request-host does not domain-match the Domain
     attribute.

   * The request-host is a FQDN (not IP address) and has the form HD,
     where D is the value of the Domain attribute, and H is a string
     that contains one or more dots.

   Examples:

   * A Set-Cookie from request-host y.x.foo.com for Domain=.foo.com
     would be rejected, because H is y.x and contains a dot.



Kristol & Montulli          Standards Track                     [Page 7]

RFC 2109            HTTP State Management Mechanism        February 1997


   * A Set-Cookie from request-host x.foo.com for Domain=.foo.com would
     be accepted.

   * A Set-Cookie with Domain=.com or Domain=.com., will always be
     rejected, because there is no embedded dot.

   * A Set-Cookie with Domain=ajax.com will be rejected because the
     value for Domain does not begin with a dot.

Meinungen von Perl Monk et al. Zu Cookies und IP-Adressen

In Bezug auf IP-Adresse und Cookie konnte ich nur die folgende Beschreibung finden

Fully-qualified host name (FQHN) means either the fully-qualified
   domain name (FQDN) of a host (i.e., a completely specified domain
   name ending in a top-level domain such as .com or .uk), or the
   numeric Internet Protocol (IP) address of a host.  The fully
   qualified domain name is preferred; use of numeric IP addresses is
   strongly discouraged.

Also, wenn Sie sich das Verhalten ansehen

Cookie set to IP number?

You can set a cookie to an IP address. You just cannot wildcard it! So while -domain=>'.289.11.63.71' is invalid, ->domain=>'289.11.63.71' is not (get rid of the period before the first set of numbers).

Fazit

Beispielcode

Recommended Posts

Überprüfung von [email protected]
12 von Array
Überprüfung der Auswirkungen auf die Leistung bei Verwendung von Java Volatile
[Überprüfung] Vergleich der Spring Boot- mit der Micronaut-Boot-Geschwindigkeit