lundi 7 mai 2018

How to inject current_user with params coming from AWS Cognito?

I have recently decided to move my user base and authentication to AWS Cognito from Device. Reson for this is, my team is developing mobile apps and rails is the backend API. I have created a custom strategy ( AWS Cognito) and configured on the device to use my custom strategy. My authentication is working as expected and I am getting the user-specific attributes from the AWS Cognito. But, I do not how to populate my attributes into the device current_user object. For simplicity and maintaining the existing relations among my entities, I still maintaining local users table with only minimum information such as username, role and of course the primary key.

Can someone help me, how to populate the current_user with cognito attributes?

Following is my pseudo code for warden custom strategy:

module Devise module Strategies class CognitoAuthenticatable < Authenticatable def authenticate! client = get_aws_cognito if resp = client.initiate_auth(username,pwd) user_attrs_from_aws_cognito = resp.get_user(resp.access_token) ### How to populate user_attrs_from_aws_cognito to current user success! else fail!("In valid login") end end end end end

Aucun commentaire:

Enregistrer un commentaire