All Projects → ryanmcgrath → Jelly

ryanmcgrath / Jelly

Licence: other
User authentication/sessions/etc for Actix-Web. More of a sample project than a crate, but probably useful to some people.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Jelly

Totp Cli
A cli-based pass-backed TOTP app
Stars: ✭ 76 (-3.8%)
Mutual labels:  authentication
Auth
Authentication, authorization and access control for PHP
Stars: ✭ 80 (+1.27%)
Mutual labels:  authentication
Cierge
🗝️ Passwordless OIDC authentication done right
Stars: ✭ 1,245 (+1475.95%)
Mutual labels:  authentication
Spring Boot Oauth2 Jwt Swagger Ui
Spring Boot , OAuth 2 , JWT (Json Web Token) and Swagger UI
Stars: ✭ 77 (-2.53%)
Mutual labels:  authentication
Brandenburg
Laravel Authentication Package
Stars: ✭ 79 (+0%)
Mutual labels:  authentication
Themis
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.
Stars: ✭ 1,232 (+1459.49%)
Mutual labels:  authentication
Openidconnect Rs
OpenID Connect Library for Rust
Stars: ✭ 75 (-5.06%)
Mutual labels:  authentication
Securelogin
This version won't be maintained!
Stars: ✭ 1,259 (+1493.67%)
Mutual labels:  authentication
Charon
Authorization and authentication service.
Stars: ✭ 79 (+0%)
Mutual labels:  authentication
Go Alone
A simple to use, high-performance, Go (golang) MAC signer.
Stars: ✭ 82 (+3.8%)
Mutual labels:  authentication
Coherence
Coherence is a full featured, configurable authentication system for Phoenix
Stars: ✭ 1,207 (+1427.85%)
Mutual labels:  authentication
Pow
Robust, modular, and extendable user authentication system
Stars: ✭ 1,213 (+1435.44%)
Mutual labels:  authentication
Vouch Proxy
an SSO and OAuth / OIDC login solution for Nginx using the auth_request module
Stars: ✭ 1,239 (+1468.35%)
Mutual labels:  authentication
Vonage Java Sdk
Vonage Server SDK for Java. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 75 (-5.06%)
Mutual labels:  authentication
Starhackit
StarHackIt: React/Native/Node fullstack starter kit with authentication and authorisation, data backed by SQL, the infrastructure deployed with GruCloud
Stars: ✭ 1,253 (+1486.08%)
Mutual labels:  authentication
Shibboleth Oidc
OpenID Connect support for the Shibboleth Identity Provider v3
Stars: ✭ 75 (-5.06%)
Mutual labels:  authentication
Keycloak Clojure
A Clojure library helping the integration of Keycloak with a Clojure Application + a sample SPA Client and API Server demonstrating the Keycloak integration
Stars: ✭ 81 (+2.53%)
Mutual labels:  authentication
Ueberauth
An Elixir Authentication System for Plug-based Web Applications
Stars: ✭ 1,259 (+1493.67%)
Mutual labels:  authentication
Rust rocket api authentication
An example of API written in Rust with the rocket.rs framework, with a JWT Authentication
Stars: ✭ 82 (+3.8%)
Mutual labels:  authentication
Authenticationintro
Stars: ✭ 82 (+3.8%)
Mutual labels:  authentication

NOTICE

This project is archived, as the actix-web 1.0 API is a bit different. It's kept up, though, for insight on how some general patterns work.

Jelly

This is a sample repository showcasing a rather straightforward way to handle user sessions, signup, and authentication in an actix-web project. I extracted it from something I'm working on as I realized that it can be otherwise tricky to figure out at a glance how all of this fits together (actix-web is still fairly fast moving, and the docs can be... rough).

You might be interested in this project if:

  • You want a sample Rust/actix-web project to kick off that has (mostly) sane defaults, and built-in user accounts.
  • You're unsure about how to structure an actix-web project, and want an opinionated (not even necessarily correct) starter.
  • You're not interested in putting a puzzle together for something as basic as user authentication, and just want it to work.

You might also not be interested in this, and that's cool too. It's licensed as a "do whatever you want" type deal, so... clone away and have fun. Some extra notes are below.

Setup

  • Clone the repo
  • mv example.env .env, and fill in the values in there
  • diesel migration run to create the user database table
  • cargo run to... well, run it. Depending on whether you have diesel_cli installed you might need that too.

Protip: You can integrate zxcvbn with the existing Validator infrastructure. I didn't rip it out of my stuff for some other reasons, but it works really well!

Notes

This is probably still a bit rough around the edges, since I ripped it out of an existing project of mine, but the key things I wanted to solve were:

  • User signup/login, with mostly secure cookie defaults
  • An easy way to check the current active user/session on each request
  • Figuring out how the hell to shove Redis in here - sessions are stored in there instead of the built-in CookieSessionBackend you'll find that ships with actix-web.

There's some "middleware" here (src/users/middleware.rs) that makes it easy to check the authentication status for the request, and load the associated User record. The first one, request.is_authentication(), simply checks the session to see if we have anything indicating a User is set. The second one, request.user(), returns a future that'll provide the actual User object.

FutureResponse and future_redirect are some wrappers around actix-web response formats to make the ergonomics of all of this more readable. You can take 'em or leave 'em.

use users::middleware::UserAuthentication;
use utils::responses::{FutureResponse, future_redirect};

fn view(request: HttpRequest) -> FutureResponse {
    // Check the session is valid, without a database hit to load the user
    if let Err(e) = request.is_authenticated() {
        return future_redirect("http://www.mozilla.com/");
    }

    // Call over to Postgres and get that there user
    request.user().then(|a| match a {
        Ok(user) => {
            future_redirect("http://www.duckduckgo.com/")
        },

        Err(_) => {
            future_redirect("http://www.google.com/")
        }
    }).responder()
}

If I was the kind to use Rust nightly in a project, I'd be interested in a derive-esque macro to check auth, ala Django's @login_required decorator.

Also, as you read the code, you may notice a lot of this is influenced by Django. I think they got the user model stuff right at some point over the years. Thanks to the djangohashers package, this even matches the password hashing Django does.

Oh, and randomly, this includes a simple library for sending emails via Postmark, since I enjoy their service.

Questions, Comments, Etc?

License

Do what you want. Read the license, it'll say the same.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].