Skip to content

Commit

Permalink
Rustify (#2)
Browse files Browse the repository at this point in the history
* Rewrite it in rust

* Version bump

* Amend the tests to use the help argument

* Update rpassword

* Use forked keyring for now

* Remove some OSes from build list

* Remove some OSes from build list
  • Loading branch information
jonathanmorley authored Dec 14, 2017
1 parent 39baebd commit f746515
Show file tree
Hide file tree
Showing 2,914 changed files with 729 additions and 1,508,258 deletions.
29 changes: 3 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

oktaws
/target/
**/*.rs.bk
Cargo.lock
134 changes: 134 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Based on the "trust" template v0.1.1
# https://github.com/japaric/trust/tree/v0.1.1

dist: trusty
language: rust
services: docker
sudo: required

# TODO Rust builds on stable by default, this can be
# overridden on a case by case basis down below.

env:
global:
# TODO Update this to match the name of your project.
- CRATE_NAME=oktaws

matrix:
# TODO These are all the build jobs. Adjust as necessary. Comment out what you
# don't need
include:
# Android
# - env: TARGET=aarch64-linux-android DISABLE_TESTS=1
# - env: TARGET=arm-linux-androideabi DISABLE_TESTS=1
# - env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1
# - env: TARGET=i686-linux-android DISABLE_TESTS=1
# - env: TARGET=x86_64-linux-android DISABLE_TESTS=1

# iOS
# - env: TARGET=aarch64-apple-ios DISABLE_TESTS=1
# os: osx
# - env: TARGET=armv7-apple-ios DISABLE_TESTS=1
# os: osx
# - env: TARGET=armv7s-apple-ios DISABLE_TESTS=1
# os: osx
# - env: TARGET=i386-apple-ios DISABLE_TESTS=1
# os: osx
# - env: TARGET=x86_64-apple-ios DISABLE_TESTS=1
# os: osx

# Linux
# - env: TARGET=aarch64-unknown-linux-gnu
# - env: TARGET=arm-unknown-linux-gnueabi
# - env: TARGET=armv7-unknown-linux-gnueabihf
# - env: TARGET=i686-unknown-linux-gnu
# - env: TARGET=i686-unknown-linux-musl
# - env: TARGET=mips-unknown-linux-gnu
# - env: TARGET=mips64-unknown-linux-gnuabi64
# - env: TARGET=mips64el-unknown-linux-gnuabi64
# - env: TARGET=mipsel-unknown-linux-gnu
# - env: TARGET=powerpc-unknown-linux-gnu
# - env: TARGET=powerpc64-unknown-linux-gnu
# - env: TARGET=powerpc64le-unknown-linux-gnu
# - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1
# - env: TARGET=x86_64-unknown-linux-gnu
# - env: TARGET=x86_64-unknown-linux-musl

# OSX
# - env: TARGET=i686-apple-darwin
# os: osx
- env: TARGET=x86_64-apple-darwin
os: osx

# *BSD
# - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1
# - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
# - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1

# Windows
# - env: TARGET=x86_64-pc-windows-gnu

# Bare metal
# These targets don't support std and as such are likely not suitable for
# most crates.
# - env: TARGET=thumbv6m-none-eabi
# - env: TARGET=thumbv7em-none-eabi
# - env: TARGET=thumbv7em-none-eabihf
# - env: TARGET=thumbv7m-none-eabi

# Testing other channels
# - env: TARGET=x86_64-unknown-linux-gnu
# rust: nightly
- env: TARGET=x86_64-apple-darwin
os: osx
rust: nightly

before_install:
- set -e
- rustup self update

install:
- sh ci/install.sh
- source ~/.cargo/env || true

script:
- bash ci/script.sh

after_script: set +e

before_deploy:
- sh ci/before_deploy.sh

deploy:
# TODO update `api_key.secure`
# - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new
# - Encrypt it: `travis encrypt 0123456789012345678901234567890123456789
# - Paste the output down here
api_key:
secure: "S1VNHaY6FMw1BU9tiIByMsldZGgupCpSnuMrmml5KmQDItqGkhbxlDOKi/aOhBjOmiHfjDb+lY7DdfETeUhDcBtiguiUeG3wl5qS0uJioqjonvQ2LlPjPVKTKBw+fulsVL1AzE6AKM8CyH0iZKIAEGLqlGwTW3q/8urpXk2+Ha9VFnlSTo/OYmuhR+pCPoCxuI9Un7FdYkMKAgwWA5rdMs2wWSyLcGxYlUBATbTFFaA/xoaJUT9iEVq+5/uyb9dlluinahJkeuChDRT3OcV4yK0pkw34d9KsuLIrC9pAwOQnLj4bnc+9Cryhw7HIg5af+9lDV+qGr94oWtFYtdiltlctPndtoKuaJdlaFdrL6rNXtd1IbAOx8MRtBQ8bAK+CazsHuUtOeoOgVy4iiVYnxbR9rVfs337cr+ATYjE1TJf4MtL2FqRf8zb0ydLBAIiAiHt+plzcmZBjPCPjmX8fA1YX9V39IhLSJHBUjFW7JGhRqw5JxlbrfiWQSiqhneNzPGJ/C4JULj2p2eUoIVSL2lqlnTobVedk2x89omAcIDKfaQCstle32ae0eDki5ZQ6paWUMP5/LnMnL734tOndw1xQm9eWal9WDaLAlfhMNlt/t3n7NqHGQ5XGJlmohz6HTz0Lfzg8zHoRlx//z2kEUPbGrMMaX4isSG/AqJmyLrc="
file_glob: true
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
on:
# TODO Here you can pick which targets will generate binary releases
# In this example, there are some targets that are tested using the stable
# and nightly channels. This condition makes sure there is only one release
# for such targets and that's generated using the stable channel
condition: $TRAVIS_RUST_VERSION = stable
tags: true
provider: releases
skip_cleanup: true

cache: cargo
before_cache:
# Travis can't cache files that are not readable by "others"
- chmod -R a+r $HOME/.cargo

branches:
only:
# release tags
- /^v\d+\.\d+\.\d+.*$/
- master

notifications:
email:
on_success: never
29 changes: 29 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "oktaws"
version = "0.9.0"
authors = ["Jonathan Morley <[email protected]>"]

[dependencies]
reqwest = "0.8.1"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
rusoto_core = "0.30.0"
rusoto_sts = "0.30.0"
rusoto_credential = "0.9.2"
scraper = "0.4.0"
base64 = "0.8.0"
quick-xml = "0.10.0"
rust-ini = "0.9"
structopt = "0.1.0"
structopt-derive = "0.1.0"
rpassword = "2.0.0"
text_io = "0.1.6"
failure = "0.1.1"
log = "0.3.8"
pretty_env_logger = "0.1.1"
keyring = "0.5.1"
username = "0.2.0"

[patch.crates-io]
keyring = { git = 'https://github.com/jonathanmorley/keyring-rs', branch = 'update-rpassword' }
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ curl -L -o /usr/local/bin/oktaws https://github.com/jonathanmorley/oktaws/releas
First, create an `~/.oktaws/config` file with your Okta base URL, app URL and user ARN, like below:

```
[okta]
baseUrl=https://mycompany.okta.com/
[aws_profile_name]
appUrl=https://mycompany.okta.com/app/YOUR_APP/OKTA_MAGIC/sso/saml
user_arn = arn:aws:iam::MY_ACCOUNT_ID:role/initial_role
organization = mycompany
app_id = YOUR_APP/OKTA_MAGIC
role = arn:aws:iam::MY_ACCOUNT_ID:role/initial_role
```
```https://cvent.okta.com/home/amazon_aws/0oa86lj5jeUdzcbz70x7/272?fromHome=true
The `role` value above is the ARN of the Role you would like to log in as. This can be found in the Roles section of the IAM service of your account.
You can find the other values above by going to your Identity Provider in the IAM service of your AWS account and downloading the metadata.
The metadata will contain some `<md:SingleSignOnService>` elements, where the `Location` attribute will look like https://mycompany.okta.com/app/YOUR_APP/OKTA_MAGIC/sso/saml"
The parts of this URL will correspond to the values above.
Second, ensure that the `~/.aws/credentials` file does not contain important information under the `aws_profile_name` section, as they will be overwritten with temporary credentials. This file might look like the following:
Expand Down Expand Up @@ -68,13 +72,9 @@ $ aws ec2 describe-instances
Login didn't work? Launch this program with `DEBUG=oktaws*` in your environment for more debugging info:

```sh
$ DEBUG=oktaws* oktaws production
$ RUST_LOG=oktaws=debug oktaws production
```

## Contributors

- Dimitrios Arethas [[email protected]]
- Thomas Hopkins [[email protected]]
- Lee Standen [@lstanden]
- Todd Lunter [@tlunter]
- Jonathan Morley [@jonathanmorley]
93 changes: 93 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Based on the "trust" template v0.1.1
# https://github.com/japaric/trust/tree/v0.1.1

environment:
global:
# TODO This is the Rust channel that build jobs will use by default but can be
# overridden on a case by case basis down below
RUST_VERSION: stable

# TODO Update this to match the name of your project.
CRATE_NAME: trust

# TODO These are all the build jobs. Adjust as necessary. Comment out what you
# don't need
matrix:
# MinGW
- TARGET: i686-pc-windows-gnu
- TARGET: x86_64-pc-windows-gnu

# MSVC
- TARGET: i686-pc-windows-msvc
- TARGET: x86_64-pc-windows-msvc

# Testing other channels
- TARGET: x86_64-pc-windows-gnu
RUST_VERSION: nightly
- TARGET: x86_64-pc-windows-msvc
RUST_VERSION: nightly

install:
- ps: >-
If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') {
$Env:PATH += ';C:\msys64\mingw64\bin'
} ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') {
$Env:PATH += ';C:\msys64\mingw32\bin'
}
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
- rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION%
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- rustc -Vv
- cargo -V

# TODO This is the "test phase", tweak it as you see fit
test_script:
# we don't run the "test phase" when doing deploys
- if [%APPVEYOR_REPO_TAG%]==[false] (
cargo build --target %TARGET% &&
cargo build --target %TARGET% --release &&
cargo test --target %TARGET% &&
cargo test --target %TARGET% --release &&
cargo run --target %TARGET% -- --help &&
cargo run --target %TARGET% --release -- --help
)

before_deploy:
# TODO Update this to build the artifacts that matter to you
- cargo rustc --target %TARGET% --release --bin hello -- -C lto
- ps: ci\before_deploy.ps1

deploy:
artifact: /.*\.zip/
# TODO update `auth_token.secure`
# - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new
# - Encrypt it. Go to https://ci.appveyor.com/tools/encrypt
# - Paste the output down here
auth_token:
secure: cYkRuUe/54r504klvLB4q3gO9VLIh/lvDF56viDCgdXtXEeLRQ+KfEmHwj2pciEE
description: ''
on:
# TODO Here you can pick which targets will generate binary releases
# In this example, there are some targets that are tested using the stable
# and nightly channels. This condition makes sure there is only one release
# for such targets and that's generated using the stable channel
RUST_VERSION: stable
appveyor_repo_tag: true
provider: GitHub

cache:
- C:\Users\appveyor\.cargo\registry
- target

branches:
only:
# Release tags
- /^v\d+\.\d+\.\d+.*$/
- master

notifications:
- provider: Email
on_build_success: false

# Building is done in the test phase, so we disable Appveyor's build phase.
build: false
Loading

0 comments on commit f746515

Please sign in to comment.