Skip to content

Commit c6f1207

Browse files
Merge pull request #31 from DevLabFoundry/fix/missing-config-sections
fix: adds parent config sections if not existing
2 parents a98af8c + 054beaa commit c6f1207

15 files changed

Lines changed: 406 additions & 266 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ on:
55
workflows: ['CI']
66
types:
77
- completed
8-
branches:
8+
branches:
99
- master
1010

1111
permissions:
1212
contents: write
13-
13+
1414
jobs:
1515
set-version:
1616
runs-on: ubuntu-latest
1717
if: ${{ github.event.workflow_run.head_branch == 'master' }}
1818
container:
19-
image: mcr.microsoft.com/dotnet/sdk:6.0
19+
image: mcr.microsoft.com/dotnet/sdk:6.0
2020
outputs:
2121
semVer: ${{ steps.gitversion.outputs.semVer }}
2222
steps:
@@ -36,7 +36,7 @@ jobs:
3636
id: gitversion
3737

3838
- name: echo VERSIONS
39-
run: |
39+
run: |
4040
echo "REVISION -> $GITHUB_SHA"
4141
echo "VERSION -> $GITVERSION_SEMVER"
4242
@@ -51,7 +51,7 @@ jobs:
5151
fetch-depth: 1
5252

5353
- uses: ensono/actions/eirctl-setup@v0.3.1
54-
with:
54+
with:
5555
version: latest
5656
isPrerelease: false
5757

@@ -66,7 +66,7 @@ jobs:
6666
6767
- name: Build binary
6868
run: |
69-
eirctl run pipeline bin:release --set Version=${SEMVER} --set Revision=$GITHUB_SHA
69+
eirctl run pipeline bin:release --set Version=${SEMVER} --set Revision=$GITHUB_SHA
7070
7171
- name: Release
7272
uses: softprops/action-gh-release@v2.2.1

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ By default the tool creates the session name - which can be audited including th
3939

4040
## [Usage](./docs/usage.md)
4141

42+
### [Using Custom Debug Browser](./docs/using-custom-debug-browser.md)
43+
4244
## Known Issues
4345

4446
- Even though a datadir is created to store the chromium session data it is advised to still open settings and save the username/password manually the first time you are presented with the login screen.
@@ -51,7 +53,7 @@ By default the tool creates the session name - which can be audited including th
5153

5254
## Contribute
5355

54-
Contributions to the aws-auth-cli package are most welcome from engineers of all backgrounds and skill levels.
56+
Contributions to the aws-auth-cli package are most welcome from engineers of all backgrounds and skill levels.
5557

5658
In particular the addition of extra test coverage, code enhacements.
5759

@@ -68,5 +70,5 @@ To make a contribution:
6870

6971
Inspired by/Borrowed the design for secretStore from these 2 packages:
7072

71-
- [Hiroyuki Wada](https://github.com/wadahiro) [package](https://github.com/openstandia/aws-cli-oidc)
73+
- [Hiroyuki Wada](https://github.com/wadahiro) [package](https://github.com/openstandia/aws-cli-oidc)
7274
- [Mark Wolfe](https://github.com/wolfeidau) [package](https://github.com/Versent/saml2aws)

cmd/saml.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ You should find it in the IAM portal e.g.: arn:aws:iam::1234567891012:saml-provi
167167
sc.cmd.PersistentFlags().StringVarP(&flags.SsoRegion, "sso-region", "", "eu-west-1", "If using SSO, you must set the region")
168168
sc.cmd.PersistentFlags().StringVarP(&flags.CustomExecutablePath, "executable-path", "", "", `Custom path to an executable
169169
170-
This needs to be a chromium like executable - e.g. Chrome, Chromium, Brave, Edge.
170+
This needs to be a chromium like executable - e.g. Chrome, Chromium, Brave, Edge.
171171
172172
You can find out the path by opening your browser and typing in chrome|brave|edge://version
173173
`)
174-
sc.cmd.PersistentFlags().BoolVarP(&flags.IsSso, "is-sso", "", false, `Enables the new AWS User portal login.
174+
sc.cmd.PersistentFlags().BoolVarP(&flags.IsSso, "is-sso", "", false, `Enables the new AWS User portal login.
175175
If this flag is specified the --sso-role must also be specified.`)
176176
sc.cmd.PersistentFlags().IntVarP(&flags.ReloadBeforeTime, "reload-before", "", 0, "Triggers a credentials refresh before the specified max-duration. Value provided in seconds. Should be less than the max-duration of the session")
177177
//
@@ -189,12 +189,17 @@ func samlInitConfig(customPath string) (*ini.File, error) {
189189
configPath := credentialexchange.ConfigIniFile(customPath)
190190
if _, err := os.Stat(configPath); err != nil {
191191
// creating a file
192-
rolesInit := []byte(fmt.Sprintf("; aws-cli-auth generated [role] section\n[%s]\n", credentialexchange.INI_CONF_SECTION))
192+
rolesInit := []byte(fmt.Sprintf("; aws-cli-auth generated [role] section\n[%s]\n", credentialexchange.INI_ROLE_SECTION))
193193
if err := os.WriteFile(configPath, rolesInit, 0644); err != nil {
194194
return nil, err
195195
}
196196
}
197-
return ini.Load(configPath)
197+
cfg, err := ini.Load(configPath)
198+
if err != nil {
199+
return nil, err
200+
}
201+
credentialexchange.EnsureParentSections(cfg)
202+
return cfg, nil
198203
}
199204

200205
func ConfigFromFlags(fileConfig *credentialexchange.CredentialConfig, rf *RootCmdFlags, sf *SamlCmdFlags, user string) error {

docs/using-custom-debug-browser.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Using Custom Debug Browser
2+
3+
It might be desirable to run your own debug browser for running the tests in
4+
environments such as WSL which might have no browser installed.
5+
6+
`aws-cli-auth` will look for an environment variable named `ROD_BROWSER_WS_URL`
7+
and will use this Web Socket URL as the browser to use for communications.
8+
9+
## Example (MSEdge)
10+
11+
For example, to run a debug browser using MSEdge:
12+
```bash
13+
msedge \
14+
--remote-debugging-port=9222 \
15+
--user-data-dir='C:\temp\test'
16+
```
17+
18+
> NOTE: The `--user-data-dir` parameter isn't strictly necessary, but if MSEdge
19+
> is open for whatever reason then it'll re-use that window and you won't get a
20+
> debug instance. Sometimes Windows suspends a closed window and this results in
21+
> it thinking the window is still open.
22+
23+
### WSL Usage
24+
25+
When exposing debug browsers like MSEdge the `--remote-debugging-address` is
26+
ignored. This means it binds to 127.0.0.1 explicitly which WSL (by default)
27+
can't.
28+
29+
To mitiagte this please add to your `~/.wslconfig`:
30+
```ini
31+
[wsl2]
32+
networkingMode=mirrored
33+
```
34+
35+
This will allow WSL to access ports bound to 127.0.0.1 on the Windows host as if
36+
they were bound through WSL.
37+
38+
### VSCode Tests
39+
40+
By adding a `ROD_BROWSER_WS_URL` to the `./vscode/settings.json` the tests can
41+
then use the debug browser added above. E.g.:
42+
```json
43+
"ROD_BROWSER_WS_URL": "ws://127.0.0.1:9222/devtools/browser/b28bdd90-8c1d-478b-8294-1e3fd3170f4d",
44+
```

eirctl.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import:
2-
- https://raw.githubusercontent.com/Ensono/eirctl/refs/tags/v0.9.7/shared/build/go/eirctl.yaml
2+
- https://raw.githubusercontent.com/Ensono/eirctl/refs/tags/v0.11.0/shared/build/go/eirctl.yaml
33

44
contexts:
55
bash:
66
container:
7-
name: mirror.gcr.io/bash:5.0.18-alpine3.22
7+
name: mirror.gcr.io/bash:5.3.9-alpine3.23
88

99
unit:test:
1010
container:
11+
# This container is from './hack/Dockerfile.ci'
1112
name: ghcr.io/devlabfoundry/aws-cli-auth-ci:0.3.0
1213
entrypoint: /usr/bin/env
1314
envfile:
@@ -16,6 +17,10 @@ contexts:
1617
- GO
1718

1819
pipelines:
20+
lints:
21+
- task: go:lint
22+
- task: go:vuln:check
23+
1924
build:
2025
- task: build:unix
2126
- task: build:win
@@ -63,7 +68,6 @@ tasks:
6368
export GOPATH=$PWD/.deps GOBIN=$PWD/.deps/bin
6469
CGO_ENABLED=1 go test ./... -v -coverpkg=github.com/DevLabFoundry/... -race -mod=readonly -timeout=1m -shuffle=on -buildvcs=false -coverprofile=.coverage/out -count=1 -run=$GO_TEST_RUN_ARGS | tee .coverage/test.out
6570
cat .coverage/test.out | .deps/bin/go-junit-report > .coverage/report-junit.xml
66-
.deps/bin/gocov convert .coverage/out | .deps/bin/gocov-xml > .coverage/report-cobertura.xml
6771
6872
unit:test:prereqs:
6973
description: Installs coverage and junit tools
@@ -72,9 +76,7 @@ tasks:
7276
- |
7377
mkdir -p .coverage
7478
export GOPATH="${PWD}/.deps" GOBIN="${PWD}/.deps/bin"
75-
go install github.com/jstemmer/go-junit-report@v0.9.1
76-
go install github.com/axw/gocov/gocov@v1.0.0
77-
go install github.com/AlekSi/gocov-xml@v1.0.0
79+
go install github.com/jstemmer/go-junit-report@v1.0.0
7880
7981
clean:dir:
8082
command:
@@ -155,9 +157,8 @@ tasks:
155157
sonar:coverage:prep:
156158
context: bash
157159
command:
158-
- |
160+
- |
159161
sed -i 's|github.com/DevLabFoundry/aws-cli-auth/||g' .coverage/out
160162
echo "Coverage file first 20 lines after conversion:"
161163
head -20 .coverage/out
162-
echo "Coverage file line count:"
163-
wc -l .coverage/out
164+
echo "Coverage file line count: $(wc -l .coverage/out)"

go.mod

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
module github.com/DevLabFoundry/aws-cli-auth
22

3-
go 1.25
3+
go 1.26
44

5-
toolchain go1.25.7
5+
toolchain go1.26.3
66

77
require (
8-
github.com/aws/aws-sdk-go-v2 v1.39.6
9-
github.com/aws/aws-sdk-go-v2/config v1.31.20
10-
github.com/aws/aws-sdk-go-v2/service/sts v1.40.2
11-
github.com/aws/smithy-go v1.23.2
8+
github.com/aws/aws-sdk-go-v2 v1.41.6
9+
github.com/aws/aws-sdk-go-v2/config v1.32.16
10+
github.com/aws/aws-sdk-go-v2/service/sts v1.42.0
11+
github.com/aws/smithy-go v1.25.0
1212
github.com/go-rod/rod v0.116.2
13-
github.com/rezakhademix/govalidator/v2 v2.1.2
13+
github.com/rezakhademix/govalidator/v2 v2.2.1
1414
github.com/savioxavier/termlink v1.4.3
15-
github.com/spf13/cobra v1.10.1
15+
github.com/spf13/cobra v1.10.2
1616
github.com/werf/lockgate v0.1.1
17-
github.com/zalando/go-keyring v0.2.6
18-
gopkg.in/ini.v1 v1.67.0
17+
github.com/zalando/go-keyring v0.2.8
18+
gopkg.in/ini.v1 v1.67.1
1919
)
2020

2121
require (
22+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.23 // indirect
23+
github.com/aws/aws-sdk-go-v2/service/signin v1.0.10 // indirect
2224
github.com/mattn/go-colorable v0.1.14 // indirect
23-
github.com/mattn/go-isatty v0.0.20 // indirect
25+
github.com/mattn/go-isatty v0.0.21 // indirect
2426
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
2527
github.com/rivo/uniseg v0.4.7 // indirect
26-
github.com/schollz/progressbar/v3 v3.18.0 // indirect
27-
golang.org/x/term v0.37.0 // indirect
28+
github.com/schollz/progressbar/v3 v3.19.0 // indirect
29+
golang.org/x/term v0.42.0 // indirect
2830
)
2931

3032
require (
31-
al.essio.dev/pkg/shellescape v1.6.0 // indirect
3233
dario.cat/mergo v1.0.2
33-
github.com/Ensono/eirctl v0.9.6
34-
github.com/aws/aws-sdk-go-v2/credentials v1.18.24 // indirect
35-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.13 // indirect
36-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.13 // indirect
37-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.13 // indirect
38-
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect
39-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.3 // indirect
40-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.13 // indirect
41-
github.com/aws/aws-sdk-go-v2/service/sso v1.30.3 // indirect
42-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.7 // indirect
34+
github.com/Ensono/eirctl v0.10.0
35+
github.com/aws/aws-sdk-go-v2/credentials v1.19.15 // indirect
36+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.22 // indirect
37+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.22 // indirect
38+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.22 // indirect
39+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.8 // indirect
40+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.22 // indirect
41+
github.com/aws/aws-sdk-go-v2/service/sso v1.30.16 // indirect
42+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.20 // indirect
4343
github.com/danieljoos/wincred v1.2.3 // indirect
4444
github.com/go-test/deep v1.1.1
45-
github.com/godbus/dbus/v5 v5.1.0 // indirect
45+
github.com/godbus/dbus/v5 v5.2.2 // indirect
4646
github.com/gofrs/flock v0.13.0 // indirect
4747
github.com/google/uuid v1.6.0 // indirect
4848
github.com/inconshreveable/mousetrap v1.1.0 // indirect
49-
github.com/rs/zerolog v1.34.0
49+
github.com/rs/zerolog v1.35.1
5050
github.com/spaolacci/murmur3 v1.1.0 // indirect
5151
github.com/spf13/pflag v1.0.10 // indirect
5252
github.com/ysmood/fetchup v0.5.3 // indirect
5353
github.com/ysmood/goob v0.4.0 // indirect
54-
github.com/ysmood/got v0.42.0 // indirect
54+
github.com/ysmood/got v0.42.4 // indirect
5555
github.com/ysmood/gson v0.7.3 // indirect
5656
github.com/ysmood/leakless v0.9.0 // indirect
57-
golang.org/x/crypto v0.44.0 // indirect
58-
golang.org/x/sys v0.38.0 // indirect
57+
golang.org/x/crypto v0.50.0 // indirect
58+
golang.org/x/sys v0.43.0 // indirect
5959
)
6060

6161
replace github.com/ysmood/fetchup => github.com/ysmood/fetchup v0.3.0

0 commit comments

Comments
 (0)