k70suK3-k06a7ash1 / minerva

0 stars 0 forks source link

Realmでのログイン認証処理を実装 #16

Open k70suK3-k06a7ash1 opened 2 years ago

k70suK3-k06a7ash1 commented 2 years ago

https://www.mongodb.com/docs/realm/web/authenticate/#std-label-web-authenticate

k70suK3-k06a7ash1 commented 2 years ago

ClientSDKを使うと認証状態がNode側にキャッシュされ、常に1ユーザーのセッションしか有効にならない そのため、Node側でTokenを発行し、バックエンド側ではそのTokenを元に認可処理を行うことでバックエンドとの疎通を可能にするような仕組みにする必要がある

k70suK3-k06a7ash1 commented 2 years ago

Does Realm use MongoDB? The Realm SDKs use Atlas Device Sync to synchronize app data between clients and MongoDB Atlas. Atlas Device Sync handles network access and conflict resolution in a background thread of your application, so your application logic stays the same regardless of network conditions.

k70suK3-k06a7ash1 commented 2 years ago

Client Libraryなので、backendとしての機能はもっていないかも(Tokenで認証して認可処理するみたいな)

k70suK3-k06a7ash1 commented 2 years ago

RemixはNodeが動くので、Realmは使えないかもしれない

k70suK3-k06a7ash1 commented 2 years ago

ClientSDKという建て付けらしい

k70suK3-k06a7ash1 commented 2 years ago

Viteで実装するか、RemixでHooks作ってClientで処理を発火させる Clientで処理する場合は環境変数の参照方法を別途確認必要

k70suK3-k06a7ash1 commented 2 years ago

https://www.mongodb.com/docs/realm/sdk/node/

k70suK3-k06a7ash1 commented 2 years ago

BackendはRealmNodeSDKで実装し、ClientはRealmWebSDKで実装すればTokenの生成と認可処理ができるかも

k70suK3-k06a7ash1 commented 2 years ago

Session関連のDocument https://www.mongodb.com/docs/atlas/app-services/authentication/#std-label-user-sessions

k70suK3-k06a7ash1 commented 2 years ago

Auth User For Realm Node SDK

k70suK3-k06a7ash1 commented 2 years ago

https://www.mongodb.com/docs/realm/sdk/node/examples/authenticate-users/

k70suK3-k06a7ash1 commented 2 years ago

A unique value used to confirm the user's identity. Uses the SDK confirmUser function.

k70suK3-k06a7ash1 commented 2 years ago

Tokenの取得方法 https://www.mongodb.com/docs/realm-sdks/js/latest/Realm.Auth.EmailPasswordAuth.html

k70suK3-k06a7ash1 commented 2 years ago

Realm Node SDK はプロセスごとにcurrentUserを管理しているようなので、別途Clientとbackendで認証ロジックを分離し、Tokenを発行する必要がない