All Projects → aripalo → aws-cdk-github-oidc

aripalo / aws-cdk-github-oidc

Licence: Apache-2.0 license
CDK constructs to use OpenID Connect for authenticating your Github Action workflow with AWS IAM

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to aws-cdk-github-oidc

aws-pdf-textract-pipeline
🔍 Data pipeline for crawling PDFs from the Web and transforming their contents into structured data using AWS textract. Built with AWS CDK + TypeScript
Stars: ✭ 141 (+138.98%)
Mutual labels:  cdk, aws-cdk
oidc
Easy to use OpenID Connect client and server library written for Go and certified by the OpenID Foundation
Stars: ✭ 475 (+705.08%)
Mutual labels:  openid-connect, oidc
AspNetCore6Experiments
ASP.NET Core Blazor BFF with Azure AD and Razor page
Stars: ✭ 43 (-27.12%)
Mutual labels:  openid-connect, oidc
Zitadel
ZITADEL - Cloud Native Identity and Access Management
Stars: ✭ 105 (+77.97%)
Mutual labels:  iam, openid-connect
rds-snapshot-export-to-s3-pipeline
RDS Snapshot Export to S3 Pipeline
Stars: ✭ 88 (+49.15%)
Mutual labels:  cdk, aws-cdk
Theidserver
OpenID/Connect server based on IdentityServer4
Stars: ✭ 170 (+188.14%)
Mutual labels:  iam, openid-connect
sotsera.blazor.oidc
OpenID Connect client for Blazor client-side projects
Stars: ✭ 21 (-64.41%)
Mutual labels:  openid-connect, oidc
Node Oidc Provider
OpenID Certified™ OAuth 2.0 Authorization Server implementation for Node.js
Stars: ✭ 2,018 (+3320.34%)
Mutual labels:  openid-connect, oidc
cloudpatrol
Policy as Code for the Cloud Development Kit (CDK)
Stars: ✭ 21 (-64.41%)
Mutual labels:  cdk, aws-cdk
example-oidc
OIDC (OpenID Connect) Example for http://openid.net/connect/
Stars: ✭ 221 (+274.58%)
Mutual labels:  openid-connect, oidc
Authlib
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
Stars: ✭ 2,854 (+4737.29%)
Mutual labels:  openid-connect, oidc
casdoor
An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS, QQ group: 645200447
Stars: ✭ 4,147 (+6928.81%)
Mutual labels:  iam, oidc
Oauthlib
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
Stars: ✭ 2,323 (+3837.29%)
Mutual labels:  openid-connect, oidc
Authing
🔥Authing - IDaaS/IAM solution that can Auth to web and mobile applications.
Stars: ✭ 247 (+318.64%)
Mutual labels:  iam, openid-connect
Hydra
OpenID Certified™ OpenID Connect and OAuth Provider written in Go - cloud native, security-first, open source API security for your infrastructure. SDKs for any language. Compatible with MITREid.
Stars: ✭ 11,884 (+20042.37%)
Mutual labels:  openid-connect, oidc
auth-backends
Custom authentication backends and views for edX services
Stars: ✭ 20 (-66.1%)
Mutual labels:  openid-connect, oidc
mock-oauth2-server
A scriptable/customizable web server for testing HTTP clients using OAuth2/OpenID Connect or applications with a dependency to a running OAuth2 server (i.e. APIs requiring signed JWTs from a known issuer)
Stars: ✭ 83 (+40.68%)
Mutual labels:  openid-connect, oidc
oidc-agent
oidc-agent for managing OpenID Connect tokens on the command line
Stars: ✭ 47 (-20.34%)
Mutual labels:  openid-connect, oidc
document-understanding-solution
Example of integrating & using Amazon Textract, Amazon Comprehend, Amazon Comprehend Medical, Amazon Kendra to automate the processing of documents for use cases such as enterprise search and discovery, control and compliance, and general business process workflow.
Stars: ✭ 180 (+205.08%)
Mutual labels:  cdk, aws-cdk
go-oidc-middleware
OpenID Connect (OIDC) http middleware for Go
Stars: ✭ 65 (+10.17%)
Mutual labels:  openid-connect, oidc

AWS CDK Github OpenID Connect

cdk-support release codecov


AWS CDK constructs that define:

  • Github Actions as OpenID Connect Identity Provider into AWS IAM
  • IAM Roles that can be assumed by Github Actions workflows

These constructs allows you to harden your AWS deployment security by removing the need to create long-term access keys for Github Actions and instead use OpenID Connect to Authenticate your Github Action workflow with AWS IAM.

Background information

github-aws-oidc


Getting started

npm i -D aws-cdk-github-oidc

OpenID Connect Identity Provider trust for AWS IAM

To create a new Github OIDC provider configuration into AWS IAM:

import { GithubActionsIdentityProvider } from 'aws-cdk-github-oidc';

const provider = new GithubActionsIdentityProvider(scope, 'GithubProvider');

In the background this creates an OIDC provider trust configuration into AWS IAM with an issuer URL of https://token.actions.githubusercontent.com, audiences (client IDs) configured as ['sts.amazonaws.com'] (which matches the aws-actions/configure-aws-credentials implementation) and the thumbprint as Github's a031c46782e6e6c662c2c87c76da9aa62ccabd8e


Retrieving a reference to an existing Github OIDC provider configuration

Remember, there can be only one (Github OIDC provider per AWS Account), so to retrieve a reference to existing Github OIDC provider use fromAccount static method:

import { GithubActionsIdentityProvider } from 'aws-cdk-github-oidc';

const provider = GithubActionsIdentityProvider.fromAccount(scope, 'GithubProvider');

Defining a role for Github Actions workflow to assume

import { GithubActionsRole } from 'aws-cdk-github-oidc';

const uploadRole = new GithubActionsRole(scope, 'UploadRole', {
  provider: provider,           // reference into the OIDC provider
  owner: 'octo-org',            // your repository owner (organization or user) name
  repo: 'octo-repo',            // your repository name (without the owner name)
  filter: 'ref:refs/tags/v*',   // JWT sub suffix filter, defaults to '*'
});

// use it like any other role, for example grant S3 bucket write access:
myBucket.grantWrite(uploadRole);

You may pass in any iam.RoleProps into the construct's props, except assumedBy which will be defined by this construct (CDK will fail if you do):

const deployRole = new GithubActionsRole(scope, 'DeployRole', {
  provider: provider,
  owner: 'octo-org',
  repo: 'octo-repo',
  roleName: 'MyDeployRole',
  description: 'This role deploys stuff to AWS',
  maxSessionDuration: cdk.Duration.hours(2),
});

// You may also use various "add*" policy methods!
// "AdministratorAccess" not really a good idea, just for an example here:
deployRole.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AdministratorAccess'));

Subject Filter

By default the value of filter property will be '*' which means any workflow (from given repository) from any branch, tag, environment or pull request can assume this role. To further stricten the OIDC trust policy on the role, you may adjust the subject filter as seen on the examples in Github Docs; For example:

filter value Descrition
'ref:refs/tags/v*' Allow only tags with prefix of v
'ref:refs/heads/demo-branch' Allow only from branch demo-branch
'pull_request' Allow only from pull request
'environment:Production' Allow only from Production environment

Github Actions Workflow

To actually utilize this in your Github Actions workflow, use aws-actions/configure-aws-credentials to assume a role.

At the moment you must use the master version (until AWS releases a new tag):

jobs:
  deploy:
    name: Upload to Amazon S3
    runs-on: ubuntu-latest
    permissions:
      id-token: write # needed to interact with GitHub's OIDC Token endpoint.
      contents: read
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Configure AWS credentials
      uses: aws-actions/configure-aws-credentials@master
      with:
        role-to-assume: arn:aws:iam::123456789012:role/MyUploadRole
        #role-session-name: MySessionName # Optional
        aws-region: us-east-1

    - name: Sync files to S3
      run: |
        aws s3 sync . s3://my-example-bucket

Development Status

These constructs are fresh out from the oven, since Github just announced the OpenID Connect feature as generally available. I've been playing around with the feature for some time, but the construct itself haven't yet been widely used.

These constructs will stay in v0.x.x for a while, to allow easier bug fixing & breaking changes if absolutely needed. Once bugs are fixed (if any), the constructs will be published with v1 major version and will be marked as stable.

Currently only TypeScript and Python versions provided, but before going to stable, I'll probably others (supported by JSII) depending on the amount of work required - so no promises!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].