Skip to content

Commit

Permalink
Restructured directories. Improved build pipeline. Updated readme. Ad…
Browse files Browse the repository at this point in the history
…ded app icons (shoutout @trisweb!)
  • Loading branch information
dgreene-r7 committed Apr 10, 2023
1 parent 6e282e8 commit 6793bff
Show file tree
Hide file tree
Showing 52 changed files with 2,187 additions and 1,379 deletions.
35 changes: 35 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-outdated.cjs

Large diffs are not rendered by default.

550 changes: 550 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

Large diffs are not rendered by default.

516 changes: 258 additions & 258 deletions .yarn/releases/yarn-3.4.1.cjs → .yarn/releases/yarn-3.5.0.cjs

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ packageExtensions:
"@babel/plugin-transform-react-jsx":
optional: true

yarnPath: .yarn/releases/yarn-3.4.1.cjs
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-outdated.cjs
spec: "https://mskelton.dev/yarn-outdated/v3"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"

yarnPath: .yarn/releases/yarn-3.5.0.cjs
60 changes: 43 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Awsaml

[![Build Status](https://api.travis-ci.org/rapid7/awsaml.svg?branch=master)](https://travis-ci.org/rapid7/awsaml) [![Coverage Status](https://coveralls.io/repos/github/rapid7/awsaml/badge.svg?branch=master)](https://coveralls.io/github/rapid7/awsaml?branch=master)

Awsaml is an application for providing automatically rotated temporary [AWS][]
Expand All @@ -18,10 +19,9 @@ while the application's running. Awsaml reuses the SAML response from the
identity provider, so the user doesn't need to reauthenticate every time.

You can grab prebuilt binaries for Mac, Linux, and Window from [the releases page][releases].
Awsaml is current pre-release software. Back up your `~/.aws/credentials` file
before using it, please.

## Configuration

Configuring Awsaml is a multi-step process that involves a bit of back and forth
between Amazon and your identity provider. The general flow looks like this

Expand All @@ -32,6 +32,7 @@ between Amazon and your identity provider. The general flow looks like this
5. Run Awsaml and give it your application's metadata.

### 1. Create a SAML application in your identity provider

The only tested identity provider is [Okta][]. To use Awsaml with Okta, you'll
need to create a SAML 2.0 application in Okta with the following settings

Expand Down Expand Up @@ -75,6 +76,7 @@ You should do two things with this url:
supply that file when you create an identity provider in AWS.

#### A note on naming things (if you are using Okta)

In the next two steps, you will create and name an identity provider and a role.
Be sure to choose short names (fewer than 28 characters between the two).

Expand Down Expand Up @@ -103,6 +105,7 @@ The `IDENTITY_PROVIDER_ARN` will be in this format:
```
arn:aws:iam::{ACCOUNT_ID}:saml-provider/{PROVIDER_NAME}
```

Where the `ACCOUNT_ID` is 12 digits long, and the `PROVIDER_NAME` is as long as
you want it to be.

Expand All @@ -117,6 +120,7 @@ As a consequence, between the name you give to the identity provider and the nam
you give to the role, you can only use up to 28 characters.

### 2. Create a SAML identity provider in AWS

Follow [Amazon's documentation for creating a SAML identity provider][saml-provider],
in which you will need to upload the metadata document you downloaded in the
previous step.
Expand All @@ -125,6 +129,7 @@ Save the ARN for your identity provider so you can configure it in your
application.

### 3. Create an IAM role in AWS

Follow [Amazon's documentation for creating an IAM role][iam-role] with the
following modifications:

Expand All @@ -145,7 +150,7 @@ between your role and the SAML identity provider you created. If not, you will
need to set up a trust relationship between it and your SAML identity provider
manually. Here's an example of the JSON policy document for that relationship.

~~~json
```json
{
"Version": "2012-10-17",
"Statement": [{
Expand All @@ -162,7 +167,7 @@ manually. Here's an example of the JSON policy document for that relationship.
}
}]
}
~~~
```

Replace the "issuer" value for the "SAML:iss" key in the policy document with
the issuer URL for your application. Replace the "arn:aws:iam:saml-provider"
Expand All @@ -172,6 +177,7 @@ SAML identity provider.
Save the ARN for the role so you can configure it in your application.

### 4. Update the SAML application with ARNs

Now that you have ARNs for the AWS identity provider and role, you can go back
into Okta and add them to your application. Edit your application to include the
following attributes.
Expand All @@ -189,6 +195,7 @@ provider in AWS your created.


##### Multiple Role Support

To support multiple roles, add multiple values to the `https://aws.amazon.com/SAML/Attributes/Role`
attribute. For example:

Expand All @@ -205,46 +212,61 @@ To support multiple roles, you must contact Okta support and request that the
see [this post](https://devforum.okta.com/t/multivalued-attributes/179).


### 5. Run Awsaml and give it your application's metadata.
### 5. Run Awsaml and give it your application's metadata

You can find a prebuilt binary for Awsaml on [the releases page][releases]. Grab
the appropriate binary for your architecture and run the Awsaml application. It
will prompt you for a SAML metadata URL. Enter the URL you saved in step 1. If
the URL's valid, it will prompt you to log in to your identity provider. If the
login's successful, you'll see temporary AWS credentials in the UI.

## Building
Awsaml is built using [Node][] and [Yarn][], so
make sure you've got a compatible versions installed. Then run Yarn to install
dependencies and build Awsaml.

~~~bash
Awsaml is built using [Node][] and [Yarn 3][], so
make sure you've got a compatible versions installed. Then run Yarn to install dependencies and build Awsaml.

```bash
rm -rf node_modules/
yarn install
yarn build
~~~
```

Those commands will create a "dist" folder with zipped binaries. If you only want
to create binaries for specific platforms, you can set a `PLATFORM` environment
Those commands will create a "out" folder with zipped binaries. If you only want to create binaries for specific platforms, you can set a `PLATFORM` environment
variable before building.

~~~bash
```bash
export PLATFORM=linux
yarn build
~~~
```

Allowed values for `PLATFORM` are `darwin`, `linux` and `win32`. You can build
binaries for multiple platforms by using a comma separated list.

~~~bash
```bash
export PLATFORM=darwin,linux
yarn build
~~~
```

Similarly, if you want to
specify the build architecture, you can set a `ARCH`
environment variable before building.

```bash
export ARCH=universal
export PLATFORM=darwin
yarn build
```

Supported architectures are `ia32`, `x64` , `armv7l`,
`arm64`, `mips64el`, `universal`, or `all`.

## Setup on macOS with Homebrew

A caskfile is bundled with the repository, to install Awsaml with [Homebrew][] simply run:

`wget https://raw.githubusercontent.com/rapid7/awsaml/master/brew/cask/awsaml.rb`
`brew install --cask awsaml.rb`

There might be an error and warning prompt but it should start succesfully downloading right after
When download is succesfully installed, a `awsaml was successfully installed!` prompt is displayed

Expand All @@ -253,13 +275,17 @@ When download is succesfully installed, a `awsaml was successfully installed!` p
Awsaml is licensed under a MIT License. See the "LICENSE.md" file for more
details.

## Special Thanks

* [Tristan Harward] for the app icon.

[AWS]: https://aws.amazon.com
[AssumeRoleWithSAML]: http://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithSAML.html
[releases]: https://github.com/rapid7/awsaml/releases
[Okta]: https://www.okta.com
[Node]: https://nodejs.org
[Yarn]: https://yarnpkg.com
[Yarn 3]: https://yarnpkg.com
[saml-provider]: http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml.html
[iam-role]: http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_saml.html
[Homebrew]: http://brew.sh/
[Tristan Harward]: https://github.com/trisweb
33 changes: 33 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { api } = require('@electron-forge/core');
const { initializeProxy } = require('@electron/get');
const { officialPlatformArchCombos } = require('electron-packager/src/targets');

const dir = process.cwd();
const platforms = (process.env.PLATFORM || '').split(',').filter(Boolean);
const arch = (process.env.ARCH || '').split(',').filter(Boolean);

const makeOpts = {
dir,
interactive: true,
skipPackage: false,
};

// special handling for when we want to build for all architectures
if (arch.length === 1 && arch[0].toLowerCase() === 'all') {
makeOpts.arch = 'all';
}

initializeProxy();

platforms.forEach(async (p) => {
makeOpts.platform = p;
if (makeOpts.arch !== 'all') {
makeOpts.arch = arch.filter((v) => officialPlatformArchCombos[p].includes(v)).join(',');
}

if (makeOpts.arch.length === 0) {
throw new Error(`No supported architectures specified for ${p}. Choices are ${officialPlatformArchCombos[p].join(', ')}`);
}

await api.make(makeOpts);
});
11 changes: 11 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable no-param-reassign */
module.exports = {
webpack: {
configure: (webpackConfig, { paths }) => {
webpackConfig.entry = `${__dirname}/src/renderer/index.js`;
paths.appIndexJs = `${__dirname}/src/renderer/index.js`;

return webpackConfig;
},
},
};
7 changes: 4 additions & 3 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ const awsaml = require('./package.json');
const includeFiles = [
// we need to make sure the project root directory is included
'',
'out',
...globSync('api/**'),
...globSync('build/**'),
...globSync('electron/**'),
...globSync('src/**'),
'LICENSE.md',
'package.json',
// per electron-packager's docs, a set of files in the node_modules directory are always ignored
Expand Down Expand Up @@ -46,6 +44,8 @@ const config = {
prune: true,
ignore: (p) => !includeFiles.includes(p.replace('/', '')),
name: 'Awsaml',
darwinDarkModeSupport: true,
icon: 'images/icon',
},
rebuildConfig: {},
hooks: {
Expand Down Expand Up @@ -87,6 +87,7 @@ const config = {
options: {
homepage: awsaml.repository.url.replace('.git', ''),
maintainer: awsaml.contributors.join(', '),
icon: 'images/icon.png',
},
},
},
Expand Down
Binary file added images/icon.icns
Binary file not shown.
Binary file added images/icon.ico
Binary file not shown.
Binary file added images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/[email protected]
Binary file not shown.
55 changes: 29 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,35 @@
"engines": {
"node": ">=16.0.0"
},
"packageManager": "yarn@3.4.1",
"packageManager": "yarn@3.5.0",
"scripts": {
"electron": "electron electron/electron.js",
"electron-dev": "NODE_ENV=development ELECTRON_START_URL=http://localhost:3000 electron electron/electron.js",
"react-start": "BROWSER=none; NODE_ENV=development react-scripts start",
"react-build": "react-scripts build",
"electron": "electron src/main/index.js",
"electron-dev": "NODE_ENV=development ELECTRON_START_URL=http://localhost:3000 electron src/main/index.js",
"react-start": "BROWSER=none; NODE_ENV=development craco start",
"react-build": "craco build",
"test": "jest",
"lint": "eslint '*.js' 'electron/**/*.js' 'api/**/*.js' 'src/**/*.js' 'test/**/*.js'",
"lint": "eslint '*.js' 'src/**/*.js' 'test/**/*.js'",
"report": "coveralls < ./coverage/lcov.info",
"prebuild": "rm -rf dist/ && rm -rf build/",
"build": "yarn prebuild && yarn react-build && node packager.js && yarn postbuild",
"postbuild": "node postbuild.js",
"build": "node build.js",
"show-appcast-checkpoint": "curl --compressed --location --user-agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' 'https://github.com/rapid7/awsaml/releases.atom' | /usr/bin/sed 's|<pubDate>[^<]*</pubDate>||g' | shasum --algorithm 256",
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make"
"make": "electron-forge make",
"clean": "rm -rf out && rm -rf build"
},
"homepage": "./",
"proxy": "http://localhost:2600/",
"main": "electron/electron.js",
"main": "src/main/index.js",
"dependencies": {
"@aws-sdk/client-sts": "^3.282.0",
"@aws-sdk/client-sts": "^3.309.0",
"@node-saml/passport-saml": "^4.0.2",
"@xmldom/xmldom": "^0.8.7",
"body-parser": "^1.20.2",
"cookie-parser": "^1.4.6",
"electron-squirrel-startup": "^1.0.0",
"express": "^4.18.2",
"express-session": "^1.17.3",
"ini": "^1.3.8",
"ini": "^4.0.0",
"morgan": "^1.10.0",
"passport": "^0.6.0",
"react": "^18.2.0",
Expand All @@ -55,29 +54,33 @@
"xpath.js": "^1.1.0"
},
"devDependencies": {
"@babel/core": "^7.21.0",
"@babel/eslint-parser": "^7.19.1",
"@babel/core": "^7.21.4",
"@babel/eslint-parser": "^7.21.3",
"@babel/preset-env": "^7.21.4",
"@babel/preset-react": "^7.18.6",
"@craco/craco": "^7.1.0",
"@electron-forge/cli": "^6.1.1",
"@electron-forge/core": "^6.1.1",
"@electron-forge/maker-deb": "^6.1.1",
"@electron-forge/maker-rpm": "^6.1.1",
"@electron-forge/maker-squirrel": "^6.1.1",
"@electron-forge/maker-zip": "^6.1.1",
"@electron-forge/plugin-webpack": "^6.1.1",
"@fortawesome/fontawesome-free": "^6.3.0",
"@fortawesome/fontawesome-svg-core": "^6.3.0",
"@fortawesome/free-brands-svg-icons": "^6.3.0",
"@fortawesome/free-regular-svg-icons": "^6.3.0",
"@fortawesome/free-solid-svg-icons": "^6.3.0",
"@electron/get": "^2.0.2",
"@electron/rebuild": "^3.2.10",
"@fortawesome/fontawesome-free": "^6.4.0",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-brands-svg-icons": "^6.4.0",
"@fortawesome/free-regular-svg-icons": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@popperjs/core": "^2.11.6",
"babel-jest": "^29.5.0",
"bootstrap": "^5.2.3",
"coveralls": "^3.1.1",
"electron": "^23.1.2",
"electron-rebuild": "^3.2.9",
"eslint": "^8.35.0",
"electron": "^24.0.0",
"electron-packager": "^17.1.1",
"eslint": "^8.38.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
Expand All @@ -92,12 +95,12 @@
"prismjs": "^1.29.0",
"prop-types": "^15.8.1",
"react-is": "^18.2.0",
"react-router": "^6.8.2",
"react-router-dom": "^6.8.2",
"react-router": "^6.10.0",
"react-router-dom": "^6.10.0",
"react-scripts": "^5.0.1",
"reactstrap": "^9.1.8",
"should": "^13.2.1",
"styled-components": "^5.3.8"
"styled-components": "^5.3.9"
},
"browserslist": {
"production": [
Expand Down
Loading

0 comments on commit 6793bff

Please sign in to comment.