Granted Documentation

repository·main·Indexed 23 days ago

https://github.com/fwdcloudsec/granted

A CLI tool for simplifying cloud role management and multi-account access, primarily targeting AWS. Granted enables fast role discovery and assumption, simultaneous multi-account access via browser, and encrypted credential caching. It supports MacOS, Linux, and Windows, and provides a multi-purpose binary entrypoint for both the granted and assumego CLI applications.

Tokens
579
Snippets
0
Records
5
Agent score
83%

What's inside Granted

  1. Overview of Granted

    main

    Granted is a command line interface (CLI) application designed to simplify access to cloud roles. It enables users to find and assume roles quickly and leverages native browser functionality to allow multiple cloud accounts to be accessed simultaneously in a web browser.

    Key features include:

    • Fast role discovery and assumption.
    • Simultaneous multi-account access via the browser.
    • Encrypted credential caching to prevent plaintext SSO tokens from being saved to disk.
  2. Use Granted and Assumego via the single binary entrypoint

    main

    The granted binary acts as a multi-purpose entrypoint. Its behavior changes based on the name used to invoke the executable. This allows the same binary to provide different CLI interfaces (like granted or assumego) while maintaining consistent keychain ACLs.

    • granted: The default CLI application.
    • assumego or dassumego: Invokes the assume CLI application.

    Additionally, you can force the assume CLI behavior by setting the FORCE_ASSUME_CLI environment variable to true.

  3. Use WithBeforeFuncs to add custom middleware logic to commands

    main

    The WithBeforeFuncs function allows you to wrap a *cli.Command with a sequence of cli.BeforeFunc middleware functions. These functions are executed before the command's main action.

    Key behaviors:

    1. Execution Order: The provided middleware functions run first, followed by the command's original Before function. This ensures that custom checks (like verifying configuration files) can run before standard checks (like verifying credentials).
    2. Help Bypass: If the user requests help (using -h, --help, or help), the middleware functions are skipped, allowing the help text to be displayed without being blocked by prerequisite checks.
    3. Error Precedence: If any middleware function returns an error, the execution chain stops immediately and returns that error.
  4. How ShouldShowHelp determines if help should be displayed

    main

    The ShouldShowHelp function checks the command-line arguments to determine if the user is requesting help. It returns true if any of the following arguments are present in the command arguments:

    • -h
    • --help
    • help

    This is used by middleware to skip prerequisite checks when the user only wants to see the command usage.