October 2019
Intermediate to advanced
444 pages
10h 37m
English
Authenticate your users in just a few steps:
#[macro_use]extern crate actix_web;mod middlewares;use actix_web::{http, middleware, web, App, HttpResponse, HttpServer, Responder};use jsonwebtoken::{encode, Header};use middlewares::Claims;use serde_derive::{Deserialize, Serialize};use std::env;
const PASSWORD: &str = "swordfish";pub const TOKEN_SECRET: &str = "0fd2af6f";#[derive(Debug, Serialize, Deserialize)]struct Login { password: String,}#[get("/secret")]fn authed() -> impl Responder { format!("Congrats, you ...