Plack:...:WebID(3pm)
โจ Plack::Middleware::Auth::WebID โจ
okay so bestie, this is a Perl module manual page (a 3pm one, from the User Contributed Perl Documentation collection) and it's literally called Plack::Middleware::Auth::WebID โ it's the authentication middleware for WebID ๐ฆ. Sit down, grab a strawberry, we're doing this ๐
๐ธ NAME ๐ธ
Plack::Middleware::Auth::WebID โ authentication middleware for WebID. that's the whole vibe, no notes ๐
๐ฆ SYNOPSIS ๐ฆ
here's the glow-up, copy it exactly bestie:
use Plack::Builder;
my $app = sub { ... };
my $cache = CHI->new( ... );
sub unauthenticated
{
my ($self, $env) = @_;
return [
403,
[ 'Content-Type' => 'text/plain' ],
[ '403 Forbidden' ],
];
}
builder
{
enable "Auth::WebID",
cache => $cache,
on_unauth => \&unauthenticated;
$app;
};
๐ DESCRIPTION ๐
Plack::Middleware::Auth::WebID is a WebID handler for Plack. that's it, that's the job ๐ซถ
If authentication is successful, then the handler sets $env->{WEBID} to the user's WebID URI, and sets $env->{WEBID_OBJECT} to a Web::ID object. iconic behaviour honestly ๐ญโจ
๐ CONFIGURATION ๐
๐ cache
This may be set to an object that will act as a cache for Web::ID objects.
Plack::Middleware::Auth::WebID does not care what package you use for your caching needs, fr fr. CHI, Cache::Cache and Cache should all work. In fact, any package that provides a similar one-argument get and a two-argument set ought to work. So which one should you use? Well CHI seems to be best, however it's Moose-based, so usually too slow for CGI applications. Use Cache::Cache for CGI, and CHI otherwise. slay, decisions made ๐
You don't need to set a cache at all, but if there's no cache, then reauthentication (which is computationally expensive ๐ฎโ๐จ) happens for every single request. Use of a cache with an expiration time of around 15 minutes should significantly speed up the responsiveness of a WebID-secured site. (For forking servers you probably want a cache that is shared between processes, such as a memcached cache.) ๐
๐ธ on_unauth
Coderef that will be called if authentication is not successful. You can use this to return a "403 Forbidden" page for example, or try an alternative authentication method.
The default coderef used will simply run the application as normal, but setting $env->{WEBID} to the empty string.
๐ฆ webid_class
Name of an alternative class to use for WebID authentication instead of Web::ID. Note that any such class would need to provide a compatible new constructor. no cap ๐ซก
๐ certificate_env_key
The key within $env where Plack::Middleware::Auth::WebID can find a PEM-encoded client SSL certificate.
Apache keeps this information in $env->{'SSL_CLIENT_CERT'}, so it should be no surprise that this setting defaults to 'SSL_CLIENT_CERT'. the way that it just makes sense ๐ง
โจ no_object_please
Suppresses setting $env->{WEBID_OBJECT}. $env->{WEBID} will still be set as usual. no thoughts, just the WebID ๐ฅ
๐ SERVER SUPPORT ๐
WebID is an authentication system based on the Semantic Web and HTTPS. It relies on client certificates (but not on certification authorities; self-signed certificates are OK). yes bestie, self-signed is valid here ๐
So for this authentication module to work...
- You need to be using a server which supports HTTPS.
Many web PSGI web servers (e.g. HTTP::Server::Simple, Starman, etc) do not support HTTPS natively. In some cases these are used with an HTTPS proxy in front of them.
- Your HTTPS server needs to request a client certificate from the client.
- Your HTTPS server needs to expose the client certificate to Plack via
$env.
If you're using an HTTPS proxy in front of a non-HTTPS web server, then you might need to be creative to find a way to forward this information to your backend web server. ๐จ
- The client browser needs to have a WebID-compatible certificate installed.
Nuff said. ๐
๐ Apache2 (mod_perl and CGI)
The SSLVerifyClient directive can be used to tell Apache that you want it to request a certificate from the client.
Apache is able to deposit the certificate in an environment variable called SSL_CLIENT_CERT. However by default it might not. Check out the SSLOptions directive and enable the "ExportCertData" option, or if you're using mod_perl try Plack::Middleware::Apache2::ModSSL. ๐ซถ
๐ Gepok
Gepok is one of a very small number of PSGI-compatible web servers that supports HTTPS natively. As of 0.20 it will request client certificates, but you will need to use Plack::Middleware::GepokX::ModSSL in order to make the certificate available in the PSGI $env hashref. rare HTTPS-native king ๐
๐ BUGS ๐
Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Web-ID>. do it bestie, they want to know ๐
๐ SEE ALSO ๐
Plack,Web::ID,Web::ID::FAQ.- General WebID information: <http://webid.info/>, <http://www.w3.org/wiki/WebID>, <http://www.w3.org/2005/Incubator/webid/spec/>, <http://lists.foaf-project.org/mailman/listinfo/foaf-protocols>.
- Apache mod_ssl:
Plack::Middleware::Apache2::ModSSL,Apache2::ModSSL, <http://httpd.apache.org/docs/2.0/mod/mod_ssl.html>. - Gepok:
Gepok,Plack::Middleware::GepokX::ModSSL.
๐ซถ AUTHOR ๐ซถ
Toby Inkster <tobyink@cpan.org>. thank you toby, genuinely ๐
โญ COPYRIGHT AND LICENCE โญ
This software is copyright (c) 2012 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. ๐
๐จ DISCLAIMER OF WARRANTIES ๐จ
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
like, no promises bestie, that's the whole point ๐ญ
and that's the tea ๐ โ this page is perl v5.32.1, dated 2021-09-11, and yeah the header up top said Plack:...:WebID(3pm) twice because it's from the User Contributed Perl Documentation collection. slay, we're done here ๐โจ๐ฆ
๐ฆ where this page comes from
- debian bookworm: libweb-id-perl 1.927-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libweb-id-perl 1.927-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libweb-id-perl 1.927-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libweb-id-perl 1.927-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms