This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ### About this Flow ### | |
// Using Custom Auth Flow through Amazon Cognito User Pools with Lambda Triggers to complete a 'CUSTOM_CHALLENGE'. | |
// | |
// ### About this function ### | |
// This CreateAuthChallengeSMS function (2nd of 4 triggers) creates the type of 'CUSTOM_CHALLENGE' as a one-time pass code sent via SMS. A one-time randomly generated 6-digit code (passCode) | |
// is sent via SMS (through Amazon SNS) to the user's mobile phone number during authentication. The generated passCode is stored in privateChallengeParameters.passCode and passed to the VerifyAuthChallenge function | |
// that will verify the user's entered passCode (received via SMS) into the mobile/web app matches the passCode passed privately through privateChallengeParameters.passCode. | |
// ### Next steps ### | |
// Instead of using the "crypto-secure-random-digit" library to generate random 6-digit codes, create a base32 secret for the user (if not exist) and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ### About this Flow ### | |
// Using Custom Auth Flow through Amazon Cognito User Pools with Lambda Triggers to complete a 'CUSTOM_CHALLENGE'. This is the same flow as one-time passcode generated and sent via SMS or Email. | |
// Instead, the service and user share a secret that was created during registration and both generate a 6-digit code based on the shared secret. | |
// If the two codes (typically only good for 30 seconds) match, the user is authenticated. | |
// | |
// ### About this function ### | |
// This DefineAuthChallengeCustom function (1st and 4th of 4 triggers) defines the type of challenge-response required for authentication. | |
// For HOTP, TOTP, U2F, or WebAuthn flows, we'll always use 'CUSTOM_CHALLENGE' and this function code won't change between the various auth methods. | |
// ### Next steps ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GraphQL Query - List all AWS Services from MyAWSServices Table | |
// Returned cached list and then fetch | |
func getServicesQuery(){ | |
appSyncClient?.fetch(query: ListAwsServicesQuery(), cachePolicy: .returnCacheDataAndFetch) { (result, error) in | |
if error != nil { | |
print(error?.localizedDescription ?? "") | |
return | |
} | |
guard let services = result?.data?.listAwsServices else { return } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GraphQL Mutation - Add a new AWS Service to the MyAWSService database table | |
func createServiceMutation(){ | |
// A quick sample insert | |
let createServiceInput = CreateAWSServiceInput(id: 6, shortName: "Device Farm", longName: "AWS Device Farm", serviceRegionName: "aws-device-farm-us-west-2", imageUrl: "device-farm") | |
appSyncClient?.perform(mutation: CreateAwsServiceMutation(createAWSServiceInput: createServiceInput)) { | |
(result, error) in | |
if let error = error as? AWSAppSyncClientError { | |
print("Error occurred: \(error.localizedDescription )") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import AWSAppSync // #1 | |
class AWSServicesTableViewController: UITableViewController { | |
// Reference AppSync client | |
var appSyncClient: AWSAppSyncClient? // #2 | |
// Sample data | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// As of April 25, 2019 --> Make sure to call $ 'npm install aws-sdk' to package this function before deploying to Lambda as the RDSDataService API is currently in BETA and | |
// therefore not available in the default aws-sdk included in the Node 8 engine built into Lambda. | |
// This code uses RDSDataService API for connecting to a Data API enabled Aurora Serverless database: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/RDSDataService.html | |
// Call this function with: { "sqlStatement": "SELECT * FROM <YOUR-TABLE-NAME"} | |
// Deploy this Lambda function via CloudFormation here: https://github.com/mobilequickie/rds-aurora-mysql-serverless | |
const AWS = require('aws-sdk') | |
const RDS = new AWS.RDSDataService() | |
exports.handler = async (event, context) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation CreateCustomer { | |
createCustomers(createCustomersInput: { | |
id: 2, | |
name: "Customer Two", | |
phone: "206-555-xxxx", | |
email: "[email protected]" | |
}) { | |
id | |
name | |
phone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Select * query from Aurora Serverless (w/ Data API enabled) using the "execute-sql" API | |
aws rds-data execute-sql --db-cluster-or-instance-arn "arn:aws:rds:us-east-1:xxxxxxxxxxxx:cluster:my-serverless-cluster" --schema "" \ | |
--database "MarketPlace" --aws-secret-store-arn "arn:aws:secretsmanager:us-east-1:xxxxxxxxxxxx:secret:RDSAuroraServerlessMasterSecret-3haLhV" \ | |
--sql-statements "select * from Customers" --region us-east-1 \ | |
--endpoint-url https://rds-data.us-east-1.amazonaws.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws rds create-db-cluster --db-cluster-identifier my-serverless-cluster --master-username mymasteruser \ | |
--master-user-password mymasterpassword --engine aurora --engine-mode serverless \ | |
--region us-east-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// AuthLWA | |
// | |
// Created by Hills, Dennis on 4/26/19. | |
// Copyright © 2018 Hills, Dennis. All rights reserved. | |
// | |
// Gist: https://gist.github.com/mobilequickie/77c60e2204e759ed0a72bde0478c0885 | |
// | |
import UIKit |
NewerOlder