Skip to content

Instantly share code, notes, and snippets.

@drAlberT
Last active July 14, 2019 23:31
Show Gist options
  • Select an option

  • Save drAlberT/b7410358beaa74e5b57382c5aecc173c to your computer and use it in GitHub Desktop.

Select an option

Save drAlberT/b7410358beaa74e5b57382c5aecc173c to your computer and use it in GitHub Desktop.

Revisions

  1. drAlberT revised this gist Jul 14, 2019. 1 changed file with 2 additions and 6 deletions.
    8 changes: 2 additions & 6 deletions aws-cli-saml-auth.sh
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,7 @@
    # A shell script to help getting SAML credentials into `~/.aws/credentials`

    ```
    #!/bin/bash
    # A shell script to help getting SAML credentials into `~/.aws/credentials`

    # Login URL https://sts.lseg.com/adfs/ls/idpinitiatedsignon.aspx?loginToRp=urn:amazon:webservices
    # Login URL https://sts.asdasd.com/adfs/ls/idpinitiatedsignon.aspx?loginToRp=urn:amazon:webservices

    LSE_AWS_ACCOUNT=0123456789
    LSE_AWS_ROLE="asdasdasd-role"
    @@ -23,5 +21,3 @@ aws sts assume-role-with-saml \
    /SessionToken/{ print "aws_session_token = " $2 }
    END { print "\n" }
    '
    ```
  2. drAlberT revised this gist Jul 14, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aws-cli-saml-auth.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # A shell script to help getting SAML credentials into `~/.aws/credentials`

    ```shell
    ```
    #!/bin/bash
    # Login URL https://sts.lseg.com/adfs/ls/idpinitiatedsignon.aspx?loginToRp=urn:amazon:webservices
  3. drAlberT revised this gist Jul 14, 2019. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions aws-cli-saml-auth.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    # A shell script to help getting SAML credentials into `~/.aws/credentials`

    ```shell
    #!/bin/bash
    # Login URL https://sts.lseg.com/adfs/ls/idpinitiatedsignon.aspx?loginToRp=urn:amazon:webservices
    @@ -20,3 +23,5 @@ aws sts assume-role-with-saml \
    /SessionToken/{ print "aws_session_token = " $2 }
    END { print "\n" }
    '
    ```
  4. drAlberT revised this gist Jul 14, 2019. 1 changed file with 22 additions and 0 deletions.
    22 changes: 22 additions & 0 deletions aws-cli-saml-auth.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/bin/bash

    # Login URL https://sts.lseg.com/adfs/ls/idpinitiatedsignon.aspx?loginToRp=urn:amazon:webservices

    LSE_AWS_ACCOUNT=0123456789
    LSE_AWS_ROLE="asdasdasd-role"
    LSE_AWS_PROFILE="asdasd-saml"
    LSE_SAML_PROVIDER="STS.ASDASD.COM"
    LSE_SAML_RESPONSE="PHNhbWxwOlJlc3 [..] vbnNlPg=="

    aws sts assume-role-with-saml \
    --role-arn "arn:aws:iam::${LSE_AWS_ACCOUNT}:role/${LSE_AWS_ROLE}" \
    --principal-arn "arn:aws:iam::${LSE_AWS_ACCOUNT}:saml-provider/${LSE_SAML_PROVIDER}" \
    --saml-assertion "${LSE_SAML_RESPONSE}" \
    | awk -F: '
    BEGIN { RS = "[,{}]"; print "['${LSE_AWS_PROFILE}']"}
    /:/{ gsub(/"/, "", $2) }
    /AccessKeyId/{ print "aws_access_key_id = " $2 }
    /SecretAccessKey/{ print "aws_secret_access_key = " $2 }
    /SessionToken/{ print "aws_session_token = " $2 }
    END { print "\n" }
    '
  5. drAlberT revised this gist Jul 14, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion regexp_collection.md
    Original file line number Diff line number Diff line change
    @@ -4,5 +4,5 @@
    _allow only RFC 1918 classes, excluding localhost and being between /16 and /28_

    ```
    AllowedPattern: '^(?:10\\.(?:25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})|172\\.(?:1[6-9]|2[0-9]|3[0-1])|192\\.168)(?:\\.(?:25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})){2}/(?:2[0-8]|1[6-9])$'
    AllowedPattern: '^(?:10\.(?:25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})|172\.(?:1[6-9]|2[0-9]|3[0-1])|192\.168)(?:\.(?:25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})){2}/(?:2[0-8]|1[6-9])$'
    ```
  6. drAlberT revised this gist Jul 14, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions regexp_collection.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Validation regular expressions for common AWS resources
    # A collection of usefull regexp

    ## CIDR Blocks (VPC and subnets)
    ### Validate AWS CloudFormation CIDR Blocks (VPC and subnets)
    _allow only RFC 1918 classes, excluding localhost and being between /16 and /28_

    ```
  7. drAlberT created this gist Jul 14, 2019.
    8 changes: 8 additions & 0 deletions regexp_collection.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    # Validation regular expressions for common AWS resources

    ## CIDR Blocks (VPC and subnets)
    _allow only RFC 1918 classes, excluding localhost and being between /16 and /28_

    ```
    AllowedPattern: '^(?:10\\.(?:25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})|172\\.(?:1[6-9]|2[0-9]|3[0-1])|192\\.168)(?:\\.(?:25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})){2}/(?:2[0-8]|1[6-9])$'
    ```