GithubHelp home page GithubHelp logo

login-rs's Introduction

認証システム

Axum Webフレームワークでのログインの実装の確認(mock model)
axum-extraクレートを用いてCookieのやり取りを行っている。
かなり適当なtodoアプリ

Endpoints

  • get method : "sign/:id => サインイン
  • post method: "/user/create => サインアップ
  • post method: "/todo => todo作成 (ユーザ認証が必要)
  • get method : "/todo" => 全ユーザーの全todoを取得

Getting Start

  1. http://localhost:3000/user/create
    にアクセスし、新規ユーザのためのJson bodyを送る

    {
        "user_name": "ferris"
    }

    この時のレスポンスは以下のようにidが付与される

    {
        "user_id": "5",
        "user_name": "ferris"
    }
  2. http://localhost:3000/sign/5
    にアクセスするとCookieが発行される。

    test_session_id = $argon2id$v%3D19$m%3D19456%2Ct%3D2%2Cp%3D1$GryY17H...18kP0; Max-Age=120;...
    
  3. http://localhost:3000/todo
    でCookieと以下のtodo JsonをPostする

    test_session_id = $argon2id$v%3D19$m%3D19456%2Ct%3D2%2Cp%3D1$GryY17H...18kP0;
    
    {
        "text": "todo things"
    }

    レスポンスは以下のようになる

    {
        "todo_id": 1,
        "user_id":  "5",
        "text": "todo things"
    }

Caution⚠️

今回はAxumでのsession管理がどのようにできるか適当にテストするためであり、セキュリティの問題を多く抱えている。
そのため、実際の開発ではセキュリティに関し、十分に考慮する必要がある。

login-rs's People

Contributors

nakaryo716 avatar

Watchers

 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.