Thread HTML Login Seite ohne php vor CSRF Angriffe schützen (32 answers)
Opened by Rambo at 2020-01-10 14:53

Linuxer
 2021-04-13 10:04
#193206 #193206
User since
2006-01-27
3870 Artikel
HausmeisterIn

user image
Hm, die metacpan Suche ist eigentlich sehr "tolerant" oder ignorant, was Groß-/Kleinschreibung angeht.

CPAN:CGI::Cookie
CPAN:CGI::cookie
CPAN:CGI::cookie()

Alle diese Suchen liefern mir hier direkt als ersten Treffer CPAN:CGI::Cookie

Um zu erfahren, ob "beide Schreibweisen zum selben Quellcode" führen, muss man nur in den Modul-Quellcode von CPAN:CGI schauen.

Ich finde über https://metacpan.org/source/LEEJO/CGI-4.51/lib%2FC... folgenden Code für CGI::cookie():

Code (perl): (dl )
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
...

#### Method: cookie
# Set or read a cookie from the specified name.
# Cookie can then be passed to header().
# Usual rules apply to the stickiness of -value.
#  Parameters:
#   -name -> name for this cookie (optional)
#   -value -> value of this cookie (scalar, array or hash) 
#   -path -> paths for which this cookie is valid (optional)
#   -domain -> internet domain in which this cookie is valid (optional)
#   -secure -> if true, cookie only passed through secure channel (optional)
#   -expires -> expiry date in format Wdy, DD-Mon-YYYY HH:MM:SS GMT (optional)
####
sub cookie {
    my($self,@p) = self_or_default(@_);
    my($name,$value,$path,$domain,$secure,$expires,$httponly,$max_age,$samesite) =
        rearrange([NAME,[VALUE,VALUES],PATH,DOMAIN,SECURE,EXPIRES,HTTPONLY,'MAX-AGE',SAMESITE],@p);
 
    require CGI::Cookie;
 
    # if no value is supplied, then we retrieve the
    # value of the cookie, if any.  For efficiency, we cache the parsed
    # cookies in our state variables.
    unless ( defined($value) ) {
        $self->{'.cookies'} = CGI::Cookie->fetch;
         
        # If no name is supplied, then retrieve the names of all our cookies.
        return () unless $self->{'.cookies'};
        return keys %{$self->{'.cookies'}} unless $name;
        return () unless $self->{'.cookies'}->{$name};
        return $self->{'.cookies'}->{$name}->value if defined($name) && $name ne '';
    }
 
    # If we get here, we're creating a new cookie
    return undef unless defined($name) && $name ne '';  # this is an error
 
    my @param;
    push(@param,'-name'=>$name);
    push(@param,'-value'=>$value);
    push(@param,'-domain'=>$domain) if $domain;
    push(@param,'-path'=>$path) if $path;
    push(@param,'-expires'=>$expires) if $expires;
    push(@param,'-secure'=>$secure) if $secure;
    push(@param,'-httponly'=>$httponly) if $httponly;
    push(@param,'-max_age'=>$max_age) if $max_age;
    push(@param,'-samesite'=>$samesite) if $samesite;
 
    return CGI::Cookie->new(@param);
}

...


Daran ist erkennbar, dass CGI::cookie() CPAN:CGI::Cookie einbindet und dessen Methoden verwendet (Zeilen 20, 26, 49 im obigen Code).
meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen!

View full thread HTML Login Seite ohne php vor CSRF Angriffe schützen