Skip to content

Instantly share code, notes, and snippets.

@AlJohri
Created December 20, 2018 17:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlJohri/7e166db4d25959d8be2feb45a991a2f6 to your computer and use it in GitHub Desktop.
Save AlJohri/7e166db4d25959d8be2feb45a991a2f6 to your computer and use it in GitHub Desktop.
  1. Install 1Password CLI and jq.

    brew install jq
    brew cask install 1password-cli
    
  2. Sign in to 1Password for the first time:

    op signin my.1password.com youremail@provider.com AA-AAAAAA-AAAAAA-AAAAA-AAAAA-AAAAA-AAAAA
    

    This will save your secret key to ~/.op/config. In the future you only need to type your 1Pass password.

  3. Add these functions to your shell profile. It assumes you have an entry in 1Password titled "Okta".

    function 1pass-signin() {
        eval $(op signin my)
    }
    
    function okta-password() {
        op get item Okta | jq -r '.details.fields[] | select(.designation == "password").value'
    }
    
    function okta-secret() {
        op get item Okta | jq '.details.sections[1].fields[0].v' | awk -F'[=&]' '{print $2}'
    }
    
    function cclokta() {
        if [[ $# -eq 0 ]] ; then
            echo 'Usage: cclokta <profile>'
            return 1
        fi
        profile="$1"
        1pass-signin
        okta_password="$(okta-password)" okta_onetimepassword_secret="$(okta-secret)" clokta --profile "$profile"
    }
    
  4. Refresh your shell and run cclokta bigdata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment