Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/barakadanny/rails-jwt


https://github.com/barakadanny/rails-jwt

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        



Rails Authentication with JWT


This is a template to jumpstart your projects using jwt!


Table of Contents



  1. About The Project



  2. Getting Started


  3. Usage

  4. Roadmap

  5. Contributing

  6. License

  7. Contact

  8. Acknowledgments

## About The Project

This is a Ruby on Rails application that includes a full authentication system using JSON Web Tokens (JWT). It allows users to register, login, logout and check their current status. The application uses bcrypt to hash and store passwords securely in the database. The session storage is also secured using cookies. This app is a simple and easy to use solution for adding authentication functionality to your Ruby on Rails application.

Here's why use this template:
* Easy to use: The app is pre-configured and ready to use, making it easy for developers to add authentication functionality to their projects.
* Secure: Passwords are hashed and stored securely using bcrypt, and session storage is secured using cookies.
* Flexible: The app is a simple and easy to use solution, but can also serve as a starting point for more complex authentication systems ✊🏼.

(back to top)

### Built With

* [Ruby on Rails](https://rubyonrails.org/)
* [JWT](https://jwt.io/)
* [Bcrypt](https://rubygems.org/gems/bcrypt/versions/3.1.12)
* [PostgreSQL](https://www.postgresql.org/)

(back to top)

## Getting Started

### Prerequisites

* Ruby 2.6.5 or higher
* Rails 6.0.3 or higher

### Installation

_Follow these steps to get this project locally._

1. Clone the repo
```ruby
git clone https://github.com/barakadanny/rails-jwt.git
```
2. Install dependencies
```ruby
bundle install
```
3. Create and migrate the database `config.js`
```ruby
rails db:create db:migrate
```

(back to top)

## Usage

Registering a new user

To register a new user, make a POST request to /registrations with a JSON payload containing the following keys:

* email
* password
* password_confirmation

Example

```json
{
"user": {
"email": "[email protected]",
"password": "password",
"password_confirmation": "password"
}
}
```

Logging a new user

* email
* password

Example

```json
{
"user": {
"email": "[email protected]",
"password": "password"
}
}

```

To log out a user, make a DELETE request to /logout.

Checking current user status

To check if a user is currently logged in, make a GET request to /logged_in.

(back to top)

## Roadmap

- [ ] Forgot Password: Implement a forgot password feature that allows users to reset their password.
- [ ] OAuth2: Add support for OAuth2 authentication so users can log in with their Google or Facebook account.
- [ ] Two-factor authentication: Implement two-factor authentication for added security.
- [ ] Admin role: Add an admin role that allows certain users to have access to administrative features.
- [ ] API authentication: Add authentication for the API endpoints.

(back to top)

## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

(back to top)

## License

Distributed under the MIT License. See `LICENSE.txt` for more information.

(back to top)

## Contact

Baraka Danny - [LinkedIn](https://www.linkedin.com/in/danny-baraka/)

(back to top)

## Acknowledgments

* [Jordan Hudgens](https://github.com/jordanhudgens)

(back to top)