amazon web services - How to use Firebase's email & password authentication method to connect with AWS to make Fine Uploader S3 work? -
i decided utilize fine uploader current angularjs project (which connected hosted on firebase) because has many core features need in uploader built in but, having problem understanding how utilize firebase's email & password authentication method communicate aws (amazon web services) allow users utilize fine uploader s3 upload content. based on fine uploader blog post uploads without server code, workflow goes like:
authenticate users help of identity provider, such google use temporary token id provider grab temporary access keys aws pass keys on fine uploader s3 your users can upload s3 bucketthe problem won't using oauth 2.0 (which used google, facebook or amazon provide user identities) allow user's sign app , upload content. instead using firebase's email & password authentication.
so how can create firebase's email & password authentication method create temporary token grab temporary access keys aws , pass keys on fine uploader s3 allow users upload content s3?
to connect aws outside application, cognito going solution. allow generate openid token using aws node sdk , secret keys in backend, can utilize aws javascript sdk , webidentitycredentials
in client.
note i'm unfamiliar specific plugin/tool, much @ to the lowest degree openid , in work allow me connect using webidentitycredentials
, imagine using.
setup on cognito easy - more or less walkthrough. involve configuring iam rules on aws, though. how set pretty project specific, think need point official resources. they made nice updates, admittedly not speed on changes.
through configuration, want setup 'developer authenticated identity', take note of 'identity pool id', , iam role arn setup cognito.
setup node server can handle incoming routesthere lot of materials out there on how accomplish this, want sure include , configure aws sdk. recommend using body-parser create reading in post requests easier.
var app = express(); var bodyparser = require('body-parser'); var aws = require('aws-sdk'); app.use(bodyparser.urlencoded({ extended: true })); app.use(bodyparser.json());
create post function talk cognito once have server setup, reach out cognito using getopenidtokenfordeveloperidentity. in setup, utilize authenticated users because expect them come , want able go on associations, why send in userid in req.body.useridfromangularapp
.
this function using express.router()
.
.post(function(req, res) { if(req.body.useridfromangularapp) { var cognitoidentity = new aws.cognitoidentity(); var params = { identitypoolid: 'your_cognito_identity_pool_id', logins: { 'your_developer_authenticated_identity_name': req.body.useridfromangularapp } }; cognitoidentity.getopenidtokenfordeveloperidentity(params, function(err, data) { if (err) { console.log(err, err.stack); res.json({failure: 'connection failure'}); } else { console.log(data); // can see result server side res.json(data); // send } }); } else { res.json({failure: 'connection failure'}); } });
if goes well, homecoming openid token you. can homecoming angular application.
post angular, collect promiseat to the lowest degree need post new node server , collect openid token out of promise. using pattern, found in data.token
.
it sounds there may need pass token on plugin/tool.
in case need handle authentication further, have included code handle webidentitycredentials
.
angular.module('yourapp').factory('awsmaker', ['$http', function($http) { homecoming { reachcognito: function(authdata) { $http.post('http://localhost:8888/simpleapi/aws', { 'useridfromangularapp': authdata.uid, }) .success(function(data, status, headers, config) { if(!data.failure) { var params = { rolearn: your_role_arn_setup_by_cognito, webidentitytoken: data.token }; aws.config.credentials = new aws.webidentitycredentials(params, function(err) { console.log(err, err.stack); }); } }); } }]);
this should on way. allow me know if can help further.
authentication amazon-web-services amazon-s3 fine-uploader amazon-cognito
No comments:
Post a Comment