iamgo

package module
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2022 License: MIT Imports: 4 Imported by: 38

README

iamgo

iamgo is a Go package for parsing/assembling AWS IAM policy documents, as the official SDK does not seem to fully support this.

It handles the multiple possible types for various IAM elements and hides this complexity from the consumer.

Example

package main

import (
    "fmt"
    
    "github.com/liamg/iamgo"
)

func main() {

    rawJSON := []byte(`...`)

    doc, err := iamgo.Parse(rawJSON)
    if err != nil {
        panic(err)
    }
    fmt.Printf("Done: %#v\n", doc)
}

Documentation

Index

Constants

View Source
const (
	EffectAllow = "Allow"
	EffectDeny  = "Deny"
)
View Source
const (
	VersionUndefined = ""
	Version20121017  = "2012-10-17"
	Version20181017  = "2008-10-17"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	// contains filtered or unexported fields
}

func (*Bool) UnmarshalJSONWithMetadata

func (b *Bool) UnmarshalJSONWithMetadata(node jfather.Node) error

type Condition

type Condition struct {
	// contains filtered or unexported fields
}

func (*Condition) Key

func (c *Condition) Key() (string, Range)

func (*Condition) Operator

func (c *Condition) Operator() (string, Range)

func (*Condition) Value

func (c *Condition) Value() ([]string, Range)

type Conditions

type Conditions struct {
	// contains filtered or unexported fields
}

func (Conditions) MarshalJSON

func (c Conditions) MarshalJSON() ([]byte, error)

func (*Conditions) UnmarshalJSONWithMetadata

func (c *Conditions) UnmarshalJSONWithMetadata(node jfather.Node) error

type Document

type Document struct {
	// contains filtered or unexported fields
}

func Parse

func Parse(policy []byte) (*Document, error)

func ParseString

func ParseString(policy string) (*Document, error)

func (*Document) ID

func (d *Document) ID() (string, Range)

func (*Document) MarshalJSON

func (d *Document) MarshalJSON() ([]byte, error)

func (*Document) Statements

func (d *Document) Statements() ([]Statement, Range)

func (*Document) UnmarshalJSONWithMetadata

func (d *Document) UnmarshalJSONWithMetadata(node jfather.Node) error

func (*Document) Version

func (d *Document) Version() (string, Range)

type PolicyBuilder

type PolicyBuilder struct {
	// contains filtered or unexported fields
}

func NewPolicyBuilder

func NewPolicyBuilder() *PolicyBuilder

func PolicyBuilderFromDocument added in v0.0.4

func PolicyBuilderFromDocument(doc Document) *PolicyBuilder

func (*PolicyBuilder) Build

func (p *PolicyBuilder) Build() Document

func (*PolicyBuilder) WithId

func (p *PolicyBuilder) WithId(id string, lines ...int) *PolicyBuilder

func (*PolicyBuilder) WithStatement

func (p *PolicyBuilder) WithStatement(s Statement, lines ...int) *PolicyBuilder

func (*PolicyBuilder) WithVersion

func (p *PolicyBuilder) WithVersion(version string, lines ...int) *PolicyBuilder

type Principals

type Principals struct {
	// contains filtered or unexported fields
}

func (*Principals) AWS

func (p *Principals) AWS() ([]string, Range)

func (*Principals) All

func (p *Principals) All() (bool, Range)

func (*Principals) CanonicalUsers

func (p *Principals) CanonicalUsers() ([]string, Range)

func (*Principals) Federated

func (p *Principals) Federated() ([]string, Range)

func (Principals) MarshalJSON

func (p Principals) MarshalJSON() ([]byte, error)

func (*Principals) Service

func (p *Principals) Service() ([]string, Range)

func (*Principals) UnmarshalJSONWithMetadata

func (p *Principals) UnmarshalJSONWithMetadata(node jfather.Node) error

type Range

type Range struct {
	StartLine int
	EndLine   int
}

type Statement

type Statement struct {
	// contains filtered or unexported fields
}

func (*Statement) Actions

func (s *Statement) Actions() ([]string, Range)

func (*Statement) Conditions

func (s *Statement) Conditions() ([]Condition, Range)

func (*Statement) Effect

func (s *Statement) Effect() (string, Range)

func (Statement) MarshalJSON

func (s Statement) MarshalJSON() ([]byte, error)

func (*Statement) NotActions

func (s *Statement) NotActions() ([]string, Range)

func (*Statement) NotPrincipals

func (s *Statement) NotPrincipals() (Principals, Range)

func (*Statement) NotResource

func (s *Statement) NotResource() ([]string, Range)

func (*Statement) Principals

func (s *Statement) Principals() (Principals, Range)

func (*Statement) Range

func (s *Statement) Range() Range

func (*Statement) Resources

func (s *Statement) Resources() ([]string, Range)

func (*Statement) SID

func (s *Statement) SID() (string, Range)

func (*Statement) UnmarshalJSONWithMetadata

func (s *Statement) UnmarshalJSONWithMetadata(node jfather.Node) error

type StatementBuilder

type StatementBuilder struct {
	// contains filtered or unexported fields
}

func NewStatementBuilder

func NewStatementBuilder() *StatementBuilder

func (*StatementBuilder) Build

func (s *StatementBuilder) Build() Statement

func (*StatementBuilder) WithAWSPrincipals

func (s *StatementBuilder) WithAWSPrincipals(aws []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithActions

func (s *StatementBuilder) WithActions(actions []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithAllPrincipals

func (s *StatementBuilder) WithAllPrincipals(all bool, lines ...int) *StatementBuilder

func (*StatementBuilder) WithCanonicalUsersPrincipals

func (s *StatementBuilder) WithCanonicalUsersPrincipals(cu []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithCondition

func (s *StatementBuilder) WithCondition(operator string, key string, value []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithEffect

func (s *StatementBuilder) WithEffect(effect string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithFederatedPrincipals

func (s *StatementBuilder) WithFederatedPrincipals(federated []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithNotAWSPrincipals

func (s *StatementBuilder) WithNotAWSPrincipals(aws []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithNotActions

func (s *StatementBuilder) WithNotActions(actions []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithNotAllPrincipals

func (s *StatementBuilder) WithNotAllPrincipals(all bool, lines ...int) *StatementBuilder

func (*StatementBuilder) WithNotCanonicalUsersPrincipals

func (s *StatementBuilder) WithNotCanonicalUsersPrincipals(cu []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithNotFederatedPrincipals

func (s *StatementBuilder) WithNotFederatedPrincipals(federated []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithNotResources

func (s *StatementBuilder) WithNotResources(resources []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithNotServicePrincipals

func (s *StatementBuilder) WithNotServicePrincipals(service []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithRange

func (s *StatementBuilder) WithRange(start, end int) *StatementBuilder

func (*StatementBuilder) WithResources

func (s *StatementBuilder) WithResources(resources []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithServicePrincipals

func (s *StatementBuilder) WithServicePrincipals(service []string, lines ...int) *StatementBuilder

func (*StatementBuilder) WithSid

func (s *StatementBuilder) WithSid(sid string, lines ...int) *StatementBuilder

type Statements

type Statements struct {
	// contains filtered or unexported fields
}

func (Statements) MarshalJSON

func (s Statements) MarshalJSON() ([]byte, error)

func (*Statements) UnmarshalJSONWithMetadata

func (s *Statements) UnmarshalJSONWithMetadata(node jfather.Node) error

type String

type String struct {
	// contains filtered or unexported fields
}

func (String) MarshalJSON

func (d String) MarshalJSON() ([]byte, error)

func (*String) UnmarshalJSONWithMetadata

func (s *String) UnmarshalJSONWithMetadata(node jfather.Node) error

type Strings

type Strings struct {
	// contains filtered or unexported fields
}

func (Strings) MarshalJSON

func (d Strings) MarshalJSON() ([]byte, error)

func (*Strings) UnmarshalJSONWithMetadata

func (s *Strings) UnmarshalJSONWithMetadata(node jfather.Node) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL