On Github gianarb / angularconf-2015
AngularConf 2015
I'm here to protect you
Without servers where do you store private credentials?
Helps your client app to manage authentication and it opens the doors of AWS world
// app/app.js .config([function() { var creds = new AWS.CognitoIdentityCredentials({ IdentityPoolId: 'us-east-1:0000000000000008c3c-5397a17ad174' }); AWS.config.update({ region: 'us-east-1', credentials: creds }); }]);
.directive('googleSignin', function() { return { restrict: 'A', template: '<span id="signinButton"></span>', replace: true, scope: { afterSignin: '&' }, link: function(scope, ele, attrs) { // see ng-newsletter.com/posts/aws-js-sdk.html } }; })
// app/view/view.tpl.html <p>This is the partial for view 1.</p> <h2>Signin to ngroad</h2> <div google-signin client-id='3818201' after-signin="signedIn(oauth)" data-user="user"></div> <pre>{{ user | json }}</pre>
$scope.signedIn = function(oauth) { var creds = { params: {} }; $scope.user = oauth; creds = AWS.config.credentials; creds.params.Logins = {}; creds.params.Logins['accounts.google.com'] = oauth.id_token; AWS.config.update({ credentials: creds }); AWS.config.credentials.refresh(function(err){ if (err) { console.log(err); } }); };
Chamber of Secrets was open
is a fully managed NoSQL database service that erovides fast and predictable performance with seamless scalability
<p>This is the partial for view 1.</p> <h2>Signin to ngroad</h2> <div google-signin client-id='38182010900-e5l22mddk7oliohktn747trqgsfau1rd' after-signin="signedIn(oauth)" data-user="user"></div> <pre>{{ user | json }}</pre> <form ng-submit="send(item)"> <input ng-model="item.title"> <button type="submit">Save</button> </form>
$scope.send = function(item) { AWS.config.getCredentials(function(){ var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'}); dynamodb.putItem({ Item: { "title": {"S": item.title} }, TableName: "angular-conf" }, function(err, data) { if(err) { throw err; } }); }); };
Allow permission for single lines
Allow permission for single columns
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem", "dynamodb:DeleteItem" ], "Resource": ["arn:aws:dynamodb:us-west-2::table/GameScores"], "Condition": { "ForAllValues:StringEquals": { "dynamodb:LeadingKeys": ["${www.amazon.com:user_id}"]} } } ] }
SQS
S3
Cognito Sync
docs.aws.amazon.com/AWSJavaScriptSDK