9/14-Rails

https://medium.com/javascript-in-plain-english/how-to-integrate-vue-into-a-rails-app-part-1-32ce8f68f54c

https://www.webcyou.com/?p=9464
Knockについて
Rails APIでの認証のgem
[認証]
人や物の対象について、正当性を確認すること。2種類ある。
Authentication-二者間認証
サーバへのログインなど。あらかじめ認証情報を認証場所で保持しておき、
非人称者からの情報をもとに認証の可否を決定する。

②Certification-三者間認証
PKI-公開鍵基盤などの仕組み。

[前提条件]
・Userモデルに対して絶対に置くべきもの。
has_secure_password
実装では共通化されているUsableに配置している。

[使い方]

・application_controller
include Knock::Authenticable
ここで使用宣言

②守りたいAPIに対してauthenticate_userを付与する
before_action :authenticate_user
・administrator_site_controllerの
before_action :authenticate_user


・routes.rb
post '/login', to: 'administrator_token#create'
post '/login', to: 'user_token#create'
・user_token_controller


Knockのセッションコントローラーにpostしたら、
{jwt:xxxxx}
みたいなjsonを返す。
②そのjsonをもって、get /my/token としてログイン情報を取りに行って、
user_token#show administrator_token#showとなって、
(実装ではshowメソッドない→)module Authenticatableのshowメソッドでjson返す
Next Post Previous Post
No Comment
Add Comment
comment url