home / content / repos

repos: 474468776

This data as json

id node_id name full_name private owner html_url description fork created_at updated_at pushed_at homepage size stargazers_count watchers_count language has_issues has_projects has_downloads has_wiki has_pages forks_count archived disabled open_issues_count license topics forks open_issues watchers default_branch permissions temp_clone_token organization network_count subscribers_count readme readme_html allow_forking visibility is_template template_repository web_commit_signoff_required has_discussions
474468776 R_kgDOHEfRqA datasette-auth0 simonw/datasette-auth0 0 9599 https://github.com/simonw/datasette-auth0 Datasette plugin that authenticates users using Auth0 0 2022-03-26T21:19:31Z 2022-03-27T17:59:49Z 2022-03-28T03:04:52Z   11 3 3 Python 1 1 1 1 0 0 0 0 0 apache-2.0 ["auth0", "datasette", "datasette-plugin"] 0 0 3 main {"admin": false, "maintain": false, "push": false, "triage": false, "pull": false}     0 1 # datasette-auth0 [![PyPI](https://img.shields.io/pypi/v/datasette-auth0.svg)](https://pypi.org/project/datasette-auth0/) [![Changelog](https://img.shields.io/github/v/release/simonw/datasette-auth0?include_prereleases&label=changelog)](https://github.com/simonw/datasette-auth0/releases) [![Tests](https://github.com/simonw/datasette-auth0/workflows/Test/badge.svg)](https://github.com/simonw/datasette-auth0/actions?query=workflow%3ATest) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-auth0/blob/main/LICENSE) Datasette plugin that authenticates users using [Auth0](https://auth0.com/) See [Simplest possible OAuth authentication with Auth0](https://til.simonwillison.net/auth0/oauth-with-auth0) for more about how this plugin works. ## Installation Install this plugin in the same environment as Datasette. $ datasette install datasette-auth0 ## Demo You can try this out at [datasette-auth0-demo.datasette.io](https://datasette-auth0-demo.datasette.io/) - click on the top right menu icon and select "Sign in with Auth0". ## Initial configuration First, create a new application in Auth0. You will need the domain, client ID and client secret for that application. The domain should be something like `mysite.us.auth0.com`. Add `http://127.0.0.1:8001/-/auth0-callback` to the list of Allowed Callback URLs. Then configure these plugin secrets using `metadata.yml`: ```yaml plugins: datasette-auth0: domain: "$env": AUTH0_DOMAIN client_id: "$env": AUTH0_CLIENT_ID client_secret: "$env": AUTH0_CLIENT_SECRET ``` Only the `client_secret` needs to be kept secret, but for consistency I recommend using the `$env` mechanism for all three. In development, you can run Datasette and pass in environment variables like this: ``` AUTH0_DOMAIN="your-domain.us.auth0.com" \ AUTH0_CLIENT_ID="...client-id-goes-here..." \ AUTH0_CLIENT_SECRET="...secret-goes-here..." \ datasette -m metadata.yml ``` If you are deploying using `datasette publish` you can pass these using `--plugin-secret`. For example, to deploy using Cloud Run you might run the following: ``` datasette publish cloudrun mydatabase.db \ --install datasette-auth0 \ --plugin-secret datasette-auth0 domain "your-domain.us.auth0.com" \ --plugin-secret datasette-auth0 client_id "your-client-id" \ --plugin-secret datasette-auth0 client_secret "your-client-secret" \ --service datasette-auth0-demo ``` Once your Datasette instance is deployed, you will need to add its callback URL to the "Allowed Callback URLs" list in Auth0. The callback URL should be something like: https://url-to-your-datasette/-/auth0-callback ## Usage Once installed, a "Sign in with Auth0" menu item will appear in the Datasette main menu. You can sign in and then visit the `/-/actor` page to see full details of the `auth0` profile that has been authenticated. You can then use [Datasette permissions](https://docs.datasette.io/en/stable/authentication.html#configuring-permissions-in-metadata-json) to grant or deny access to different parts of Datasette based on the authenticated user. ## Development To set up this plugin locally, first checkout the code. Then create a new virtual environment: cd datasette-auth0 python3 -mvenv venv source venv/bin/activate Now install the dependencies and test dependencies: pip install -e '.[test]' To run the tests: pytest <div id="readme" class="md" data-path="README.md"><article class="markdown-body entry-content container-lg" itemprop="text"><h1 dir="auto"><a id="user-content-datasette-auth0" class="anchor" aria-hidden="true" href="#user-content-datasette-auth0"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>datasette-auth0</h1> <p dir="auto"><a href="https://pypi.org/project/datasette-auth0/" rel="nofollow"><img src="https://camo.githubusercontent.com/f43e5887f316cf40043f9c8a820290d3d12ae6b474804d66627cadf27de5145b/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f6461746173657474652d61757468302e737667" alt="PyPI" data-canonical-src="https://img.shields.io/pypi/v/datasette-auth0.svg" style="max-width: 100%;"></a> <a href="https://github.com/simonw/datasette-auth0/releases"><img src="https://camo.githubusercontent.com/62decb2ba747ff51dd7bd5bdb614a6973179ff5642425c8e8525764285bc372c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f73696d6f6e772f6461746173657474652d61757468303f696e636c7564655f70726572656c6561736573266c6162656c3d6368616e67656c6f67" alt="Changelog" data-canonical-src="https://img.shields.io/github/v/release/simonw/datasette-auth0?include_prereleases&amp;label=changelog" style="max-width: 100%;"></a> <a href="https://github.com/simonw/datasette-auth0/actions?query=workflow%3ATest"><img src="https://github.com/simonw/datasette-auth0/workflows/Test/badge.svg" alt="Tests" style="max-width: 100%;"></a> <a href="https://github.com/simonw/datasette-auth0/blob/main/LICENSE"><img src="https://camo.githubusercontent.com/1698104e976c681143eb0841f9675c6f802bb7aa832afc0c7a4e719b1f3cf955/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667" alt="License" data-canonical-src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" style="max-width: 100%;"></a></p> <p dir="auto">Datasette plugin that authenticates users using <a href="https://auth0.com/" rel="nofollow">Auth0</a></p> <p dir="auto">See <a href="https://til.simonwillison.net/auth0/oauth-with-auth0" rel="nofollow">Simplest possible OAuth authentication with Auth0</a> for more about how this plugin works.</p> <h2 dir="auto"><a id="user-content-installation" class="anchor" aria-hidden="true" href="#user-content-installation"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Installation</h2> <p dir="auto">Install this plugin in the same environment as Datasette.</p> <div class="snippet-clipboard-content position-relative overflow-auto" data-snippet-clipboard-copy-content="$ datasette install datasette-auth0"><pre><code>$ datasette install datasette-auth0 </code></pre></div> <h2 dir="auto"><a id="user-content-demo" class="anchor" aria-hidden="true" href="#user-content-demo"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Demo</h2> <p dir="auto">You can try this out at <a href="https://datasette-auth0-demo.datasette.io/" rel="nofollow">datasette-auth0-demo.datasette.io</a> - click on the top right menu icon and select "Sign in with Auth0".</p> <h2 dir="auto"><a id="user-content-initial-configuration" class="anchor" aria-hidden="true" href="#user-content-initial-configuration"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Initial configuration</h2> <p dir="auto">First, create a new application in Auth0. You will need the domain, client ID and client secret for that application.</p> <p dir="auto">The domain should be something like <code>mysite.us.auth0.com</code>.</p> <p dir="auto">Add <code>http://127.0.0.1:8001/-/auth0-callback</code> to the list of Allowed Callback URLs.</p> <p dir="auto">Then configure these plugin secrets using <code>metadata.yml</code>:</p> <div class="highlight highlight-source-yaml position-relative overflow-auto" data-snippet-clipboard-copy-content="plugins: datasette-auth0: domain: &quot;$env&quot;: AUTH0_DOMAIN client_id: &quot;$env&quot;: AUTH0_CLIENT_ID client_secret: &quot;$env&quot;: AUTH0_CLIENT_SECRET"><pre><span class="pl-ent">plugins</span>: <span class="pl-ent">datasette-auth0</span>: <span class="pl-ent">domain</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-ent">$env</span><span class="pl-pds">"</span></span>: <span class="pl-s">AUTH0_DOMAIN</span> <span class="pl-ent">client_id</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-ent">$env</span><span class="pl-pds">"</span></span>: <span class="pl-s">AUTH0_CLIENT_ID</span> <span class="pl-ent">client_secret</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-ent">$env</span><span class="pl-pds">"</span></span>: <span class="pl-s">AUTH0_CLIENT_SECRET</span></pre></div> <p dir="auto">Only the <code>client_secret</code> needs to be kept secret, but for consistency I recommend using the <code>$env</code> mechanism for all three.</p> <p dir="auto">In development, you can run Datasette and pass in environment variables like this:</p> <div class="snippet-clipboard-content position-relative overflow-auto" data-snippet-clipboard-copy-content="AUTH0_DOMAIN=&quot;your-domain.us.auth0.com&quot; \ AUTH0_CLIENT_ID=&quot;...client-id-goes-here...&quot; \ AUTH0_CLIENT_SECRET=&quot;...secret-goes-here...&quot; \ datasette -m metadata.yml"><pre><code>AUTH0_DOMAIN="your-domain.us.auth0.com" \ AUTH0_CLIENT_ID="...client-id-goes-here..." \ AUTH0_CLIENT_SECRET="...secret-goes-here..." \ datasette -m metadata.yml </code></pre></div> <p dir="auto">If you are deploying using <code>datasette publish</code> you can pass these using <code>--plugin-secret</code>. For example, to deploy using Cloud Run you might run the following:</p> <div class="snippet-clipboard-content position-relative overflow-auto" data-snippet-clipboard-copy-content="datasette publish cloudrun mydatabase.db \ --install datasette-auth0 \ --plugin-secret datasette-auth0 domain &quot;your-domain.us.auth0.com&quot; \ --plugin-secret datasette-auth0 client_id &quot;your-client-id&quot; \ --plugin-secret datasette-auth0 client_secret &quot;your-client-secret&quot; \ --service datasette-auth0-demo"><pre><code>datasette publish cloudrun mydatabase.db \ --install datasette-auth0 \ --plugin-secret datasette-auth0 domain "your-domain.us.auth0.com" \ --plugin-secret datasette-auth0 client_id "your-client-id" \ --plugin-secret datasette-auth0 client_secret "your-client-secret" \ --service datasette-auth0-demo </code></pre></div> <p dir="auto">Once your Datasette instance is deployed, you will need to add its callback URL to the "Allowed Callback URLs" list in Auth0.</p> <p dir="auto">The callback URL should be something like:</p> <div class="snippet-clipboard-content position-relative overflow-auto" data-snippet-clipboard-copy-content="https://url-to-your-datasette/-/auth0-callback"><pre><code>https://url-to-your-datasette/-/auth0-callback </code></pre></div> <h2 dir="auto"><a id="user-content-usage" class="anchor" aria-hidden="true" href="#user-content-usage"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Usage</h2> <p dir="auto">Once installed, a "Sign in with Auth0" menu item will appear in the Datasette main menu.</p> <p dir="auto">You can sign in and then visit the <code>/-/actor</code> page to see full details of the <code>auth0</code> profile that has been authenticated.</p> <p dir="auto">You can then use <a href="https://docs.datasette.io/en/stable/authentication.html#configuring-permissions-in-metadata-json" rel="nofollow">Datasette permissions</a> to grant or deny access to different parts of Datasette based on the authenticated user.</p> <h2 dir="auto"><a id="user-content-development" class="anchor" aria-hidden="true" href="#user-content-development"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Development</h2> <p dir="auto">To set up this plugin locally, first checkout the code. Then create a new virtual environment:</p> <div class="snippet-clipboard-content position-relative overflow-auto" data-snippet-clipboard-copy-content="cd datasette-auth0 python3 -mvenv venv source venv/bin/activate"><pre><code>cd datasette-auth0 python3 -mvenv venv source venv/bin/activate </code></pre></div> <p dir="auto">Now install the dependencies and test dependencies:</p> <div class="snippet-clipboard-content position-relative overflow-auto" data-snippet-clipboard-copy-content="pip install -e '.[test]'"><pre><code>pip install -e '.[test]' </code></pre></div> <p dir="auto">To run the tests:</p> <div class="snippet-clipboard-content position-relative overflow-auto" data-snippet-clipboard-copy-content="pytest"><pre><code>pytest </code></pre></div> </article></div> 1 public 0      

Links from other tables

  • 2 rows from repo in releases
Powered by Datasette · Queries took 2.992ms