Git Product home page Git Product logo

laravel7-sanctum-token-multiauth's Introduction

📝 About

本リポジトリは、Laravel Sanctumのサンプル実装です。 APIトークンを利用した認証を考慮しつつ、Multi Authを実装しています。

※ セッション認証は別途調査する予定

📝 認証について

App/UserApp/Adminの複数Modelで、Sanctumを利用し認証します。
データについては事前にFactoryを利用し登録しています。

  • ログイン処理
  • ログインユーザーの取得

を中心に実装しています。

📝 APIリクエスト

URL 説明
/api/login UserログインAPI
/api/me ログインユーザー取得API
/admin/api/login AdminログインAPI
/admin/api/me ログイン管理ユーザー取得API

UserログインAPI

/api/login - UserログインAPI

curl --request POST \
  --url http://127.0.0.1:8000/api/login \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{
	"email": "[email protected]",
	"password": "password"
}'

ログインユーザー取得API

/api/me - ログインユーザー取得API

curl --request GET \
  --url http://localhost:8000/api/me \
  --header 'accept: application/json' \
  --header 'authorization: Bearer 6|oW3GIXpw48kcfAc1FcqA4gm4zOBFfVgNVGdMCqIImFMzoaEmTqSY4fsOFNxXymPnXPFXU5mfMYg7pMI7'

AdminログインAPI

/admin/api/login - AdminログインAPI

curl --request POST \
  --url http://127.0.0.1:8000/admin/api/login \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{
	"email": "[email protected]",
	"password": "password"
}'

ログイン管理ユーザー取得API

/admin/api/me - ログイン管理ユーザー取得API

curl --request GET \
  --url http://127.0.0.1:8000/admin/api/me \
  --header 'accept: application/json' \
  --header 'authorization: Bearer 4|dbtGtsoXAyE7VH1yaIpvDsI3F2UqelBl2YkOI8j17xvqCgfU5k4kk9D37OhlBpTur2uJUcttwCGSFV1U'

Tools

License

The Laravel framework is open-sourced software licensed under the MIT license.

laravel7-sanctum-token-multiauth's People

Contributors

ynaka6 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.