Add Facebook and Google authentication to your HTTP REST API in Actix-web

Overview

I created this project while learning Rust. Project shows how to handle Facebook and Google token verification in Rust using Actix-Web. Hope this helps somebody out there.

How does it work?

  • All magic happens in this file on this line
  • Next, include AuthenticatedUser struct in your routes like this on line 9
  • Under the hood, it uses google-jwt-verify library to verify Google Sign-in token and uses reqwest to verify Facebook token. Once verified, it stores the token details in Redis with auto expiration time based on the token expiration time.

How to use?

  • Make sure to add Google client ID, Facebook details in .env file. Once .env file is filled, this data should seamlessly flow to the rest of the application.
  • User would authenticate using Google Sign in or Facebook Login in the browser.
    • Browser would submit either google or facebook token in Authorization header of the HTTP request
    • Actix will verify the token and proceed depending on whether token is valid/invalid. If invalid, returns 401 error. If valid, it proceeds with rest of the steps.
    • For this App, all GET requests are non-authenticated so they are allowed without any verification.

Note: Instead of using google-jwt-verify crate, this project uses a local forked copy of it. I simply modified to handle Async mutation in the library. Similar changes were submitted by other user. Hence, I kept my changes local. All credits go to the author of this library.

You might also like...
REST-like API micro-framework for Rust. Works with Iron.

Table of Contents What is Rustless? Usage warning Basic Usage Complex example Mounting Parameters validation and coercion Use JSON Schema Query string

Operator is a web server. You provide a directory and Operator serves it over HTTP.
Operator is a web server. You provide a directory and Operator serves it over HTTP.

Operator Operator is a web server. You provide a directory and Operator serves it over HTTP. It serves static files the way you'd expect, but it can a

Archibald is my attempt at learning Rust and writing a HTTP 1.1 web server.
Archibald is my attempt at learning Rust and writing a HTTP 1.1 web server.

Archibald To be a butler, is to be able to maintain an even-temper, at all times. One must have exceptional personal hygiene and look sharp and profes

Google Cloud Client Libraries for Rust.

google-cloud-rust Rust packages for Google Cloud Platform services. Providing a high level API for gRPC API like Google Cloud Go. Component google-clo

A dead simple human-writable URL redirector based loosely on google's `go/` system.

Redirector a redirector written in rust intended for permanent human-readable redirects. The idea was semi-inspired by the book Software Engineering a

Cookiecutter Rust Actix template for jumpstarting production-ready projects quickly.

Cookiecutter actix simple clean architecture This is a reusable Rust Cookiecutter template. The project is based on Actix web in combination with Dies

Fahrenheit-celsius converter using actix

fahrenheit-celsius-converter Simple http Fahrenheit/Celsius/Kelvin converter using actix-web. Note This is a toy project, not yet finished. It's not r

Opinionated Rust authentication library.
Opinionated Rust authentication library.

Goals Prevent user enumeration. All routes should be protected against user enumeration, for now we should at least protect against basic enumeration

Host These Things Please - a basic http server for hosting a folder fast and simply

http Host These Things Please - a basic HTTP server for hosting a folder fast and simply Selected features See the manpage for full list. Symlinks fol

Owner
null
Basic Actix + Diesel + Postgres REST API

Actix-Crud Basic Actix + Diesel + Postgres REST API Setup Install and setup PostgreSQL Set DATABASE_URL environment variable or specify in .env file g

Aathif Naseer 4 Sep 23, 2022
Example Actix 2.x REST application implementing many features

Rust/Actix Example An Actix 2.0 REST server using the Rust language. Motivation Actix Web is a fast, powerful web framework for building web applicati

David D. 238 Dec 31, 2022
Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix Web Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust Features Supports HTTP/1.x and HTTP/2 Streaming and pipelining

Actix 16.3k Jan 8, 2023
A starter template for actix-web projects that feels very Django-esque. Avoid the boring stuff and move faster.

Jelly A.K.A, the actix-web starter you probably wish you had. This is provided as-is, and anyone is free to extend it or rework it as they desire - ju

SecretKeys 198 Dec 15, 2022
In-progress extractors and middleware for Actix Web

actix-web-lab Experimental extractors, middleware, and other extras for possible inclusion in Actix Web. Things To Know About This Crate It will never

Rob Ede 51 Dec 20, 2022
Extension for actix-web to validate user permissions

actix-web-grants Extension for actix-web to validate user permissions. To check user access to specific services, you can use built-in proc-macro, Per

Artem Medvedev 114 Dec 22, 2022
Easy to use multipart forms for actix-web

Actix Easy Multipart Easy to use Multipart Forms for actix-web. File uploads are written to disk as temporary files similar to the way the $_FILES var

Jacob Halsey 17 Jan 3, 2023
Example Blog using Rust, Actix Web, HTMX, Mustache

Actix Blog An example blog built with Actix. It uses htmx and handlebar templates. Running To run the blog, you need to have a recent version of Rust

Dru Jensen 2 Nov 11, 2022
Actix-web wrapper for garde, a Rust validation library.

Garde-actix-web   Actix-web wrapper for garde, a Rust validation library. Installation Usage example Feature flags About us Installation [dependencies

Netwo 5 Sep 8, 2023
Static Web Server - a very small and fast production-ready web server suitable to serve static web files or assets

Static Web Server (or SWS abbreviated) is a very small and fast production-ready web server suitable to serve static web files or assets.

Jose Quintana 496 Jan 2, 2023