Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/barakadanny/rails-jwt
https://github.com/barakadanny/rails-jwt
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/barakadanny/rails-jwt
- Owner: barakadanny
- Created: 2023-01-25T22:35:25.000Z (almost 2 years ago)
- Default Branch: dev
- Last Pushed: 2023-01-26T10:46:14.000Z (almost 2 years ago)
- Last Synced: 2024-05-17T15:35:41.890Z (7 months ago)
- Language: Ruby
- Size: 50.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Rails Authentication with JWT
This is a template to jumpstart your projects using jwt!
Table of Contents
## 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 ✊🏼.### 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/)## 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
```## Usage
Registering a new user
To register a new user, make a POST request to /registrations with a JSON payload containing the following keys:
* password
* password_confirmationExample
```json
{
"user": {
"email": "[email protected]",
"password": "password",
"password_confirmation": "password"
}
}
```Logging a new user
* passwordExample
```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.
## 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.## 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## License
Distributed under the MIT License. See `LICENSE.txt` for more information.
## Contact
Baraka Danny - [LinkedIn](https://www.linkedin.com/in/danny-baraka/)
## Acknowledgments
* [Jordan Hudgens](https://github.com/jordanhudgens)