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
|
NAME
Web::Solid::Auth - A Perl Solid Web Client
SYNOPSIS
# On the command line
# Set your default webid
export SOLID_WEBID=https://timbl.inrupt.net/profile/card#me
# Authentication to a pod
solid_auth authenticate
# Get the http headers for a authenticated request
solid_auth headers GET https://timbl.inrupt.net/inbox/
# Act like a curl command and fetch authenticated content
solid_auth curl -X GET https://timbl.inrupt.net/inbox/
# Add some data
solid_auth curl -X POST \
-H "Content-Type: text/plain" \
-d "abc" \
https://timbl.inrupt.net/public/
# Add a file
solid_auth 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 list /public/
# Get some data
solid_auth get /inbox/
# Post some data
solid_auth post /inbox/ myfile.jsonld
# Put some data
solid_auth put /public/myfile.txt myfile.txt
# Create a folder
solid_auth put /public/mytestfolder/
# Delete some data
solid_auth delete /public/myfile.txt
# Mirror a resource, container or tree
solid_auth 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 -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 --keep clean /demo/
# Clean a complete container
# Add the -x option to do it for real (only a test without this option)
solid_auth -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
See the https://metacpan.org/dist/Web-Solid-Auth/source/INSTALL file in
the distribution.
DESCRIPTION
This is a Solid-OIDC implementation of a connection class for the Solid
server. Use the bin/solid_auth command as a command line
implementation. Check out the example directory for a demo web
application.
CONFIGURATION
webid
The Solid Webid to authenticate.
cache
The location of the cache directory with connection parameters.
METHODS
has_access_token()
Returns a true value when a cache contains an access token for the
webid.
make_clean()
Clear the cache directory.
make_authorization_request()
Return an authorization URL that the use should open to authenticate
this application.
make_access_token($code)
When on the redirect url you get a code from the authentication
server you can use this method to get an access_token for the code.
listen()
Create a small built-in web server to listen for token responses from
the authentication server.
get_access_token()
Return the cached access_token.
SEE ALSO
solid_auth
INSPIRATION
This was very much inspired by the Python solid-flask code by Rai
http://agentydragon.com at https://gitlab.com/agentydragon/solid-flask,
and Jeff Zucker's <https://github.com/jeff-zucker> Solid-Shell at
https://www.npmjs.com/package/solid-shell.
COPYRIGHT AND LICENSE
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.
|