Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

gofor-little/aws-auth

Repository files navigation

A package for authentication via AWS Cognito

GitHub tag (latest SemVer pre-release) GitHub go.mod Go version License: MIT GitHub Workflow Status Go Report Card PkgGoDev

Introduction

  • Authenticate users via AWS Cognito

Example

package main

import (
	"context"

	auth "github.com/gofor-little/aws-auth"
)

func main() {
	// Initialize the auth package.
	if err := auth.Initialize(context.Background(), "AWS_PROFILE", "AWS_REGION", "USER_POOL_ID", "CLIENT_ID"); err != nil {
		panic(err)
	}

	// Sign in.
	if _, err := auth.SignIn(context.Background(), "john@example.com", "password1234"); err != nil {
		panic(err)
	}
}

Testing

Ensure the following environment variables are set, usually with a .env file.

  • AWS_PROFILE (an AWS CLI profile name)
  • AWS_REGION (a valid AWS region)

Run go test ./... at the root of the project.