Skip to content

eoinclayton/appsync-csharp-oidc

Repository files navigation

Serverless AppSync OIDC

A quick example of how to setup AWS AppSync with Dotnet Core Lambda Resolvers using Open Id Connect (OIDC) authorization

General info

I started investigating how to use AWS AppSync for one of my work projects, but found the examples online were either overly complex or didn't show how to connect to an OIDC authorizer such as Identity Server 4. This repo therefore is a stripped down HelloWorld solution which shows just what you need to use AppSync + Lambdas + OIDC.

Prerequisites

You will need an AWS account with the AWS cli installed and working

Setup

  1. Clone the repo
  2. Install Serverless if you haven't already got it setup locally
npm install -g serverless
  1. A plugin that is used, Serverless AppSync Plugin, needs to be installed via npm:
    npm install
  1. Set the url of your OIDC provider by updating "https://issuer_goes_here.com" in the serverless.yml file Issuer Setting
  2. Build the dotnet core code
    ./build.sh
  1. Deploy
    sls deploy

All going well the deployment will success and you'll get back the Service Information

Service Information
service: myappsynctest
stage: dev
region: ap-southeast-2
stack: myappsynctest-dev
resources: 14
api keys:
   None
appsync api keys:
   None
endpoints:
   None
appsync endpoints:
   https://dq6kysaxwvhbvit7itwcjd3zqm.appsync-api.ap-southeast-2.amazonaws.com/graphql
functions:
   graphql: myappsynctest-dev-graphql

Be sure to take note of the appsync endpoint. You'll need it later. The deployment will create an AppSync api within your AWS account: Postman headers

Once deployed, how to use?

  1. Open Postman

  2. Set the following headers:

Header Value
Content-Type application/graphql
Authorization {Put your jwt access token here. No need for "Bearer ".}

Postman headers

  1. HTTP Verb: POST

  2. In the Body tab, select GraphQL and set the following body:

query {helloWorld}
  1. Enter the appsync endpoint from the deploy step above as the request url

  2. Hit send. All going well you'll get back a Hello World response Postman headers

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published