Created
February 20, 2021 16:00
-
-
Save sgswtky/62e6ad7f66da8d89bc4738361949e8ca to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"context" | |
"errors" | |
"fmt" | |
"log" | |
"github.com/aws/aws-lambda-go/lambda" | |
) | |
func main() { | |
lambda.Start(verifyAuthChallengeResponse) | |
} | |
type Req map[string]interface{} | |
func verifyAuthChallengeResponse(ctx context.Context, req Req) (interface{}, error) { | |
fmt.Println("called verify auth challenge response") | |
for k, v := range req { | |
log.Println(fmt.Sprintf("%s => %v", k, v)) | |
} | |
request, isErr := req["request"].(map[string]interface{}) | |
if !isErr { | |
return nil, errors.New("cannot convert request") | |
} | |
privateChallengeParameters := request["privateChallengeParameters"].(map[string]interface{}) | |
answer := privateChallengeParameters["answer"].(string) | |
challengeAnswer := request["challengeAnswer"].(string) | |
res, isErr := req["response"].(map[string]interface{}) | |
if !isErr { | |
return nil, errors.New("cannot convert response") | |
} | |
log.Printf("answer: %v", answer == challengeAnswer) | |
res["answerCorrect"] = answer == challengeAnswer | |
req["response"] = res | |
return req, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment