{"id":18866384,"url":"https://github.com/nordcloud/cognito-go-auth","last_synced_at":"2025-04-14T14:31:10.822Z","repository":{"id":57502711,"uuid":"194038484","full_name":"nordcloud/cognito-go-auth","owner":"nordcloud","description":"Simple library to sign requests using cognito Google federated authentication.","archived":false,"fork":false,"pushed_at":"2023-10-11T21:11:34.000Z","size":4239,"stargazers_count":17,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T03:24:48.649Z","etag":null,"topics":["aws","cli","cognito","golang","google-auth"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nordcloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-27T06:46:42.000Z","updated_at":"2023-03-09T08:15:03.000Z","dependencies_parsed_at":"2022-09-02T01:50:31.642Z","dependency_job_id":null,"html_url":"https://github.com/nordcloud/cognito-go-auth","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nordcloud%2Fcognito-go-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nordcloud%2Fcognito-go-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nordcloud%2Fcognito-go-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nordcloud%2Fcognito-go-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nordcloud","download_url":"https://codeload.github.com/nordcloud/cognito-go-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248897088,"owners_count":21179535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","cli","cognito","golang","google-auth"],"created_at":"2024-11-08T05:06:24.528Z","updated_at":"2025-04-14T14:31:10.790Z","avatar_url":"https://github.com/nordcloud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cognito-go-auth [![Build Status](https://travis-ci.org/nordcloud/cognito-go-auth.svg?branch=master)](https://travis-ci.org/nordcloud/cognito-go-auth) [![Go Report Card](https://goreportcard.com/badge/github.com/nordcloud/cognito-go-auth)](https://goreportcard.com/report/github.com/nordcloud/cognito-go-auth)\n\nCognito-go-auth is the golang library that allows you to easily generate Cognito Authentication Token and sign requests. Currently it supports only **Google federated authentication** using Cognito hosted UI.\n\n![](doc/preview.gif)\n\n\n### How it works?\n\n- It creates HTTP server on the localhost:3000 and serves HTML page with the Cognito hosted UI.\n- It creates websocket on localhost:3001 used to communicate with the web browser.\n- It automatically opens web browser.\n- When user authenticate using Google account, JS script sends the Authenticated Token to the websocket.\n\n### Installation\n\n```\ngo get github.com/nordcloud/cognito-go-auth\n```\n\n### Use source code to sign request in your application\n\nThe main use case for this library is to use the CognitoAuthorizer from the `auth` package to sign requests in your command line application.\n\nTo create cognito authorizer you can either use `NewCongitoAuthorizer` function:\n\n```\nauthorizer := NewCongitoAuthorizer(\n    cognitoUserPoolId, cognitoClientId, cognitoHostedUI\n)\n```\n\nor create it using settings from the environment variables:\n\n```\nauthorizer, err := auth.GetAuthorizerFromEnv(userPoolID, clientID, hostedUIDomain)\n```\n\nTo generate cognito Authorization token you have to execute:\n\n```\ntoken, err := authorizer.GetToken()\n```\n\nSigning requests is possible using the token.Sign(request) method. Please not that you can also manually sign request by adding `Authorization` header.\n\nYou can check `main.go` file for the example implementation of the CURL tool.\n\n\n### Use as a standalone cognito signed CURL\n\nUsage: `cognito-go-auth [flags] request_url`\n\nFlags:\n\n- `-c`, `--client-id`           AWS cognito Client ID\n- `-H`, `--header`              Request header 'HeaderName: HeaderValue'\n- `-u`, `--hosted-ui`           Addres of the hosted UI\n- `-X`, `--request`             Request method (default \"GET\")\n- `-p`, `--user-pool-id`        AWS cognito user pool ID\n- `-v`, `--verbose`             Show response status and headers\n\nYou can also use environment variables to store cognito configuration:\n\n- `USER_POOL_ID` AWS cognito user pool ID\n- `CLIENT_ID` AWS cognito Client ID\n- `HOSTED_UI` Addres of the hosted UI\n\nExample:\n\n```\ncognito-go-auth -H \"Header1: Header1Value\" -X POST https://api.application.nordcloudapp.com\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnordcloud%2Fcognito-go-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnordcloud%2Fcognito-go-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnordcloud%2Fcognito-go-auth/lists"}