GithubHelp home page GithubHelp logo

juhaszzs / actix-fb-google-login Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jbham/actix-fb-google-login

0.0 0.0 0.0 40 KB

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

Shell 0.37% Rust 95.02% PLpgSQL 4.61%

actix-fb-google-login's Introduction

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.

actix-fb-google-login's People

Contributors

jbham avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.