Web::Solid::Auth(3pm)

πŸ“¦
version 0.91 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Web::Solid::Auth β€” bestie, it's a Perl Solid Web Client. That's the whole vibe. ✨


🌸 SYNOPSIS 🌸

Okay so here's the tea, all the ways you can slide into this module's DMs:

# On the command line

# Set your default webid
export SOLID_WEBID=https://timbl.inrupt.net/profile/card#me

# Authentication to a pod
solid_auth.pl authenticate

# Get the http headers for a authenticated request
solid_auth.pl headers GET https://timbl.inrupt.net/inbox/

# Act like a curl command and fetch authenticated content
solid_auth.pl curl -X GET https://timbl.inrupt.net/inbox/

# Add some data
solid_auth.pl curl -X POST \
        -H "Content-Type: text/plain" \
        -d "abc" \
        https://timbl.inrupt.net/public/

# Add a file
solid_auth.pl curl -X PUT \
        -H "Content-Type: application/ld+json" \
        -d "@myfile.jsonld" \
        https://timbl.inrupt.net/public/myfile.jsonld

# Set a solid base url
export SOLID_REMOTE_BASE=https://timbl.inrupt.net

# List all resources on some Pod path
solid_auth.pl list /public/

# Get some data
solid_auth.pl get /inbox/

# Post some data
solid_auth.pl post /inbox/ myfile.jsonld

# Put some data
solid_auth.pl put /public/myfile.txt myfile.txt

# Create a folder
solid_auth.pl put /public/mytestfolder/

# Delete some data
solid_auth.pl delete /public/myfile.txt

# Mirror a resource, container or tree
solid_auth.pl mirror /public/ ./my_copy

# Upload a directory to the pod
#  Add the -x option to do it for real (only a test without this option)
solid_auth.pl -r upload /data/my_copy /public/

# Clean all files in a container
#  Add the -x option to do it for real (only a test without this option)
solid_auth.pl --keep clean /demo/

# Clean a complete container
#  Add the -x option to do it for real (only a test without this option)
solid_auth.pl -r clean /demo/

# In a perl program
use Web::Solid::Auth;
use Web::Solid::Auth::Listener;

# Create a new authenticator for a pod
my $auth = Web::Solid::Auth->new(webid => $webid);

# Or tune a listerner
my $auth = Web::Solid::Auth->new(
      webid     => $webid ,
      listener => Web::Solid::Auth::Listener->new(
            scheme => 'https'
            host   => 'my.server.org'
            port   => '443' ,
            path   => '/mycallback'
      )
);

# Or, in case you have your own callback server
my $auth = Web::Solid::Auth->new(
      webid         => $webid,
      redirect_uri => 'https://my.server.org/mycallback'
);

# Generate a url for the user to authenticate
my $auth_url = $auth->make_authorization_request;

# Listen for the oauth server to return tokens
# the built-in listener for feedback from the openid provider
# Check the code of Web::Solid::Auth::Listener how to
# do this inside your own Plack application
$auth->listen;

####

# If you already have access_tokens from previous step
if ($auth->has_access_token) {
    # Fetch the Authentication and DPoP HTTP headers for a
    # request to an authorized resource
    my $headers = $auth->make_authentication_headers($resource_url,$http_method);

    #..do you curl..lwp::agent..or what ever with the headers
}

πŸ› οΈ INSTALLATION πŸ› οΈ

Hit up the <https://metacpan.org/dist/Web-Solid-Auth/source/INSTALL> file inside the distribution, bestie β€” everything you need to install is right there. 🫢


πŸ‘‘ DESCRIPTION πŸ‘‘

So like, this is a Solid-OIDC implementation of a connection class for the Solid server. Slay. πŸ’… Use the solid_auth command as a command line implementation β€” and fr fr, go peep the "example" directory for a demo web application. It's giving main character energy. ✨


βš™οΈ CONFIGURATION βš™οΈ

  • webid β€” the Solid Webid you're authenticating with. Your lil identity card, basically. πŸͺͺ
  • cache β€” the location of the cache directory holding the connection parameters. It's where the secrets live. 🀫

πŸ¦‹ METHODS πŸ¦‹

  • has_access_token() β€” gives you back a true value when a cache has an access token for the "webid". Yes queen, you're logged in. πŸ”₯
  • make_clean() β€” wipes the cache directory. Fresh start, no notes. πŸ’€
  • make_authorization_request() β€” returns an authorization URL that the use should open to authenticate this application. (Yes, the original says "the use" β€” keeping it, it's iconic.) πŸŽ€
  • make_access_token($code) β€” when you're sitting on the redirect url and the authentication server hands you a "code", this is the method that turns it into an access_token. Glow up moment. ⭐
  • listen() β€” spins up a lil built-in web server to listen for token responses coming back from the authentication server. She's listening. πŸ‘‚
  • get_access_token() β€” returns the cached access_token. Come through, stored credentials. πŸ’–

πŸ” SEE ALSO πŸ”

solid_auth β€” go read it, iykyk. 🌈


🌟 INSPIRATION 🌟

This whole thing was very much inspired by the Python solid-flask code by Rai <http://agentydragon.com> over at <https://gitlab.com/agentydragon/solid-flask>, plus Jeff Zucker's <https://github.com/jeff-zucker> Solid-Shell at <https://www.npmjs.com/package/solid-shell>. Standing on the shoulders of icons. πŸ‘‘


This software is copyright (c) 2021 by Patrick Hochstenbach.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


no cap, that's the whole page bestie πŸ’œ go authenticate something

okay bye ily, this was Web::Solid::Auth(3pm) β€” perl v5.36.0, dated 2023-09-04. periodt. πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from