nomlab / camome

CAMOME MOtivates ME
1 stars 11 forks source link

camomeからgoohubへのRedisを経由したtokenの受け渡し機能を実装する #49

Open kanzawa2 opened 7 years ago

kanzawa2 commented 7 years ago

Created from AI0384 of minute 437.

kanzawa2 commented 7 years ago

現状報告

tokenを作成するために,以下の記事を参考にGoogleのOAuth認証を行い,camomeのアカウントを作成した. http://www.swlab.cs.okayama-u.ac.jp/lab/nom/articles/ikeda-y-20160928-171521

Wikiのclass_diagram_about_authenticationにまとめられているクラス図とモデルの実装を比較したところ,以下のことがわかった.

今後は,認証周りの処理を調査する.

Ryota0312 commented 7 years ago

現状報告

現在以下のような実装を行っている.

問題点

上記の問題点に対処するため,カレンダー表示時にmaster_passを要求するフォームが必要である.master_passを要求するフォームの作成は未完了である.

Ryota0312 commented 6 years ago

prompt の設定による refresh_token の発行に関する調査

devise と omniauth-google-oauth2 を用いて認証を行う場合に,refresh_token が発行される条件について調査した. 以下は prompt の設定を,設定しない,consent および select_account としたときのユーザ体験と refresh_token 発行についてまとめたものである.

promptを設定しない prompt: consent prompt: select_account
ユーザ体験 1回目のみアカウント選択 毎回アカウント選択 毎回アカウント選択
refresh_token 発行 1回目のみ発行 毎回発行 1回目のみ発行
Ryota0312 commented 6 years ago

現状報告

現在,OAuth2 による認証と認可でプロバイダを分ける実装を進めている. コミット: https://github.com/Ryota0312/camome/commit/4611e5938ef6bdbefe03f1b19c0be66f228c48cd

今回やったこと

プロバイダの分離

  1. プロバイダの追加 gem omniauth-google-oauth2 を継承し option :name の部分をオーバーライドすることで新たにプロバイダを作成する.以下の場合,google_oauth2_calendar が新たなプロバイダ名になる.

    require 'omniauth-google-oauth2'
    module OmniAuth
    module Strategies
    class GoogleOauth2Calendar < OmniAuth::Strategies::GoogleOauth2
      option :name, 'google_oauth2_calendar'
    end
    end
    end
  2. omniauth の設定

    • google_oauth2: ログイン認証用プロバイダ
    • google_oauth2_calendar: Google カレンダーへのアクセス認可用プロバイダ
      
      Rails.application.config.middleware.use OmniAuth::Builder do
      require '/camome/lib/google_oauth2_calendar.rb'
      provider :google_oauth2,
                ApplicationSettings.oauth.google.application_id,
                ApplicationSettings.oauth.google.application_secret,
                prompt: "consent",
                skip_jwt: true

    provider :google_oauth2_calendar, ApplicationSettings.oauth.google_calendar.application_id, ApplicationSettings.oauth.google_calendar.application_secret, scope: "calendar profile", prompt: "consent", skip_jwt: true end

今後の課題