### Localauth0 TOML Configuration Example Source: https://github.com/primait/localauth0/blob/master/README.md An example `localauth0.toml` file showing how to configure the issuer and user information. ```toml issuer = "https://prima.localauth0.com/" [user_info] given_name = "Locie" ``` -------------------------------- ### Example SSO Authorization URL Source: https://github.com/primait/localauth0/blob/master/README.md An example of a complete authorization URL for Localauth0 SSO, demonstrating the usage of various query parameters. ```APIDOC Example Authorization URL: http://localhost:3000/authorize?redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F&audience=audience1&client_id=client_id&connection=whatever&response_type=token&scope=whatever&state=test-state&bypass=true ``` -------------------------------- ### Run Auth0 Local Stack Server Source: https://github.com/primait/localauth0/blob/master/examples/README.md This snippet shows how to set the HOST environment variable and run the local Auth0 stack server using Cargo. ```shell export HOST='localhost:3000' cargo run ``` -------------------------------- ### Generate New JWT with Auth0 Local Stack Source: https://github.com/primait/localauth0/blob/master/examples/README.md This example demonstrates how to set the necessary environment variables (CLIENT_ID, CLIENT_SECRET, AUDIENCE) and then run a script to obtain a new JWT from the local Auth0 stack. ```shell export CLIENT_ID=client_id export CLIENT_SECRET=client_secret export AUDIENCE= examples/jwt.sh ``` -------------------------------- ### Example SSO Redirect Response Source: https://github.com/primait/localauth0/blob/master/README.md An example of the redirect URL after a successful SSO authentication with Localauth0, showing the returned token details. ```APIDOC Example Redirect Response: http://localhost:3000/#access_token=eyJ..RrQ&token_type=Bearer&expires_in=3600&state=test-state ``` -------------------------------- ### Get JWKS from Auth0 Local Stack Source: https://github.com/primait/localauth0/blob/master/examples/README.md This command executes a shell script to retrieve the JSON Web Key Set (JWKS) from the local Auth0 stack. ```shell examples/jwks.sh ``` -------------------------------- ### Preconfigured Environment Variables for Auth0 Local Stack Source: https://github.com/primait/localauth0/blob/master/examples/README.md This provides a set of commonly used environment variables for configuring the Auth0 Local Stack, including HOST, CLIENT_ID, CLIENT_SECRET, AUDIENCE, and PERMISSION. ```shell export HOST='localhost:3000' export CLIENT_ID=client_id export CLIENT_SECRET=client_secret export AUDIENCE=audience export PERMISSION=permission ``` -------------------------------- ### Install Localauth0 Docker Image Source: https://github.com/primait/localauth0/blob/master/README.md Command to run the Localauth0 Docker image. It exposes HTTP on port 3000 and HTTPS on port 3001 by default. ```shell docker run -d -p 3000:3000 public.ecr.aws/primaassicurazioni/localauth0:0.8.3 ``` -------------------------------- ### Docker Compose Configuration with Config File Mount Source: https://github.com/primait/localauth0/blob/master/README.md Example of configuring Localauth0 by mounting a `localauth0.toml` file into the container using docker-compose.yml. ```yaml auth0: image: public.ecr.aws/primaassicurazioni/localauth0:0.8.2 healthcheck: test: ["CMD", "/localauth0", "healthcheck"] environment: LOCALAUTH0_CONFIG_PATH: /etc/localauth0.toml volumes: - ./localauth0.toml:/etc/localauth0.toml:ro ports: - "3000:3000" ``` -------------------------------- ### Docker Compose Configuration with Inline Environment Variable Source: https://github.com/primait/localauth0/blob/master/README.md Example of configuring Localauth0 using an inline `LOCALAUTH0_CONFIG` environment variable within docker-compose.yml. ```yaml auth0: image: public.ecr.aws/primaassicurazioni/localauth0:0.8.2 healthcheck: test: ["CMD", "/localauth0", "healthcheck"] ports: - "3000:3000" environment: LOCALAUTH0_CONFIG: | issuer = "https://prima.localauth0.com/" [user_info] given_name = "Locie" ``` -------------------------------- ### Set Permissions for Audience in Auth0 Local Stack Source: https://github.com/primait/localauth0/blob/master/examples/README.md This snippet shows how to set the AUDIENCE and PERMISSION environment variables, and then execute a script to associate permissions with a specific audience in the local Auth0 stack. Subsequent JWT generation will include these permissions. ```shell export AUDIENCE= export PERMISSION= examples/set_permissions_for_audience.sh ``` -------------------------------- ### Build Web Dist and Run Server Source: https://github.com/primait/localauth0/blob/master/README.md Commands to build the web distribution using trunk and then run the Localauth0 server. ```shell # Build the web dist with trunk. Then run the server car go make run ``` -------------------------------- ### Build and Run Localauth0 Locally Source: https://github.com/primait/localauth0/blob/master/README.md Commands to build the Localauth0 Docker image and run it locally, mapping port 3000 and mounting the current directory. ```shell docker build -f Dockerfile -t localauth0 . && \ docker run -it -p 3000:3000 -v .:/code localauth0 bash ``` -------------------------------- ### Run Localauth0 from Docker Compose Source: https://github.com/primait/localauth0/blob/master/README.md Command to enter a running Docker Compose container for Localauth0 and execute build/run commands. ```shell docker-compose run --service-ports web bash ``` -------------------------------- ### Build and Run Localauth0 as Docker Image Source: https://github.com/primait/localauth0/blob/master/README.md Commands to build the Localauth0 Docker image and run it in detached mode, exposing port 3000. ```shell docker build -f Dockerfile -t localauth0 . && \ docker run -d -p 3000:3000 localauth0 ``` -------------------------------- ### Localauth0 SSO Authorization URL Source: https://github.com/primait/localauth0/blob/master/README.md This snippet shows the structure of the URL to initiate the SSO flow with Localauth0, including required and optional query parameters. ```APIDOC SSO Authorization: URL: http://localhost:3000/authorize Query Parameters: redirect_uri: Your web app callback page. audience: The audience for token generation. response_type (optional): 'token' for implicit grant, 'code' for authorization code flow. state (optional): Opaque value for security, returned in redirect. bypass (optional): Development feature to directly redirect to redirect_uri. ``` -------------------------------- ### Localauth0 APIs Source: https://github.com/primait/localauth0/blob/master/README.md Documentation for the Localauth0 API endpoints, covering token generation, permission management, custom claims, user info, and JWKS. ```APIDOC OAuth Token Endpoints: POST /oauth/token Description: Used to get a freshly new JWT. Request Body (client credentials grant): { "client_id": "client_id", "client_secret": "client_secret", "audience": "{{your-audience}}", "grant_type": "client_credentials" } Request Body (authorization code grant): { "client_id": "client_id", "client_secret": "client_secret", "grant_type": "authorization_code", "code": "{{your-auth-code}}" } GET /oauth/token/custom_claims Description: Used to get the list of custom claims that will be injected in the JWT payload. POST /oauth/token/custom_claims Description: Used to add or update one or more custom claim fields. Request Body: { "custom_claims": [ { "name": "custom_claim_field_name", "value": "custom claim field value. Can be a string or a list of strings" } ] } GET /oauth/token/user_info Description: Used to get the user info. POST /oauth/token/user_info Description: Used to update the user info. Request Body: { "subject": "optional field", "name": "optional field", "given_name": "optional field", "family_name": "optional field", "nickname": "optional field", "locale": "optional field", "gender": "optional field", "birthdate": "optional field", "email": "optional field", "email_verified": "optional field", "picture": "optional field", "updated_at": "optional field", "custom_fields": "optional field" } Permissions Endpoints: GET /permissions Description: Used to get the list of all audiences with their associated permissions. POST /permissions Description: Used to set a list of permissions for a given audience. These permissions will be injected in the JWT payload. Request Body: { "audience": "{{your-audience}}", "permissions": ["your-permission-1", "your-permission-2", ".."] } GET /permissions/{audience} Description: Used to get the list of all permissions for the given audience. JWKS Endpoints: GET /.well-known/jwks.json Description: Fetches the running instance's JWKS, which are randomly created from random certificates. Every generated JWT will be signed using one of these JWKS. GET /rotate Description: Discards the last JWK of the JWKS list and prepends a freshly new JWK. GET /revoke Description: Discards all the JWKs in the JWKS list and replaces them with 3 freshly new JWKs. ``` -------------------------------- ### Fixing Rust Target Error Source: https://github.com/primait/localauth0/blob/master/README.md Instructions to add the `wasm32-unknown-unknown` target for Rust, resolving common build errors related to missing targets. ```shell rustup target add wasm32-unknown-unknown --toolchain nightly ``` -------------------------------- ### Docker Compose Integration Snippet Source: https://github.com/primait/localauth0/blob/master/README.md A YAML snippet for docker-compose.yml to integrate Localauth0 as a service, including image, healthcheck, and port mapping. ```yaml auth0: image: public.ecr.aws/primaassicurazioni/localauth0:0.8.3 healthcheck: test: ["CMD", "/localauth0", "healthcheck"] ports: - "3000:3000" ``` -------------------------------- ### Localauth0 Healthcheck Command Source: https://github.com/primait/localauth0/blob/master/README.md The command to execute a healthcheck on a running Localauth0 service. ```shell localauth0 healtcheck ``` -------------------------------- ### Service Worker Registration Source: https://github.com/primait/localauth0/blob/master/web/index.html This code snippet checks if the browser supports service workers and, if so, registers the '/sw.js' service worker. It logs success or failure messages to the console. ```javascript if ("serviceWorker" in navigator) { window.addEventListener("load", function () { navigator.serviceWorker.register("/sw.js").then( function (registration) { // Registration was successful console.log("ServiceWorker registration successful with scope: ", registration.scope); }, function (err) { // registration failed :( console.log("ServiceWorker registration failed: ", err); }); }); } ``` -------------------------------- ### Localauth0 SSO Redirect Response Source: https://github.com/primait/localauth0/blob/master/README.md This snippet details the URL fragments returned after a successful SSO authentication, containing the JWT token and related information. ```APIDOC SSO Redirect Response: URL Fragments: access_token: The JWT token. token_type: Always 'Bearer'. expires_in: JWT expiration time. state: Value from the authorize URL, if provided. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.