https://github.com/workos/ruby-authkit-example
Example app for AuthKit in Ruby
https://github.com/workos/ruby-authkit-example
Last synced: 10 months ago
JSON representation
Example app for AuthKit in Ruby
- Host: GitHub
- URL: https://github.com/workos/ruby-authkit-example
- Owner: workos
- License: mit
- Created: 2024-08-29T15:31:19.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-18T21:04:05.000Z (over 1 year ago)
- Last Synced: 2025-04-11T15:12:20.486Z (about 1 year ago)
- Language: Ruby
- Size: 9.77 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ruby integration example using AuthKit
An example application demonstrating how to authenticate users with AuthKit, Sinatra and the WorkOS Ruby SDK.
> Refer to the [User Management](https://workos.com/docs/user-management) documentation for reference.
## Prerequisites
You will need a [WorkOS account](https://dashboard.workos.com/signup).
## Requirements
Ruby v3.3.4
## Running the example
1. In the [WorkOS dashboard](https://dashboard.workos.com), head to the Redirects tab and create a [sign-in callback redirect](https://workos.com/docs/user-management/1-configure-your-project/configure-a-redirect-uri) for `http://localhost:3000/callback`.
2. After creating the redirect URI, navigate to the API keys tab and copy the _Client ID_ and the _Secret Key_. Rename the `.env.example` file to `.env` and supply your Client ID and API key as environment variables.
3. Additionally, create a cookie password as the private key used to encrypt the session cookie. Copy the output into the environment variable `WORKOS_COOKIE_PASSWORD`.
It has to be exactly 32 characters long. You can use https://1password.com/password-generator/ to generate strong passwords. Alternatively, use the OpenSSL library to generate a secure password:
```bash
openssl rand -base64 24
```
4. Verify your `.env` file has the following variables filled.
```bash
WORKOS_CLIENT_ID=
WORKOS_API_KEY=
WORKOS_REDIRECT_URI=http://localhost:3000/callback
WORKOS_COOKIE_PASSWORD=
```
5. Install the dependencies
```bash
bundle install
```
6. Run the following command and navigate to [http://localhost:3000](http://localhost:3000).
```bash
ruby app.rb
```