-
Notifications
You must be signed in to change notification settings - Fork 150
feat: restore HTTP registry and provider-agnostic access provider support #937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
billyjbryant
wants to merge
11
commits into
fwdcloudsec:main
Choose a base branch
from
billyjbryant:feat/restore-http-registry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cdbe345
revert: restore CommonFate integrations removed in b0e4767
billyjbryant 664a54a
revert: restore CommonFate integrations removed in b0e4767 (#2)
billyjbryant 555a3ac
refactor: remove CF-specific proxy/eks/rds/console packages
billyjbryant 001df48
refactor: remove CF-specific proxy/eks/rds/console packages (#3)
billyjbryant 64e15f6
feat: provider-agnostic AccessProvider interface + HTTP provider
billyjbryant 11dc51d
feat: provider-agnostic AccessProvider interface + HTTP provider (#4)
billyjbryant b4f14f0
feat: OIDC auth flow for provider authentication
billyjbryant 3483d57
feat: auto-populate tenant_id from provider config
billyjbryant 77409ed
feat: OIDC auth flow for provider authentication (#5)
billyjbryant c70ed5f
fix: handle resp.Body.Close() error returns for errcheck lint
billyjbryant 3aadf59
refactor: vendor awsconfigfile, relocate httpregistry, wire up regist…
billyjbryant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| // Package accessrequest handles | ||
| // making requests to roles that a | ||
| // user doesn't have access to. | ||
| package accessrequest | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "fmt" | ||
| "net/url" | ||
| "os" | ||
| "path/filepath" | ||
|
|
||
| "github.com/common-fate/clio/clierr" | ||
| "github.com/fwdcloudsec/granted/pkg/config" | ||
| ) | ||
|
|
||
| type Role struct { | ||
| Account string `json:"account"` | ||
| Role string `json:"role"` | ||
| } | ||
|
|
||
| func (r Role) URL(dashboardURL string) string { | ||
| u, err := url.Parse(dashboardURL) | ||
| if err != nil { | ||
| return fmt.Sprintf("error building access request URL: %s", err.Error()) | ||
| } | ||
| u.Path = "access" | ||
| q := u.Query() | ||
| q.Add("type", "aws-sso") | ||
| q.Add("permissionSetArn.label", r.Role) | ||
| q.Add("accountId", r.Account) | ||
| u.RawQuery = q.Encode() | ||
|
|
||
| return u.String() | ||
| } | ||
|
|
||
| func (r Role) Save() error { | ||
| roleBytes, err := json.Marshal(r) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| configFolder, err := config.GrantedConfigFolder() | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| file := filepath.Join(configFolder, "latest-role") | ||
| return os.WriteFile(file, roleBytes, 0644) | ||
| } | ||
|
|
||
| func LatestRole() (*Role, error) { | ||
| configFolder, err := config.GrantedConfigFolder() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| file := filepath.Join(configFolder, "latest-role") | ||
|
|
||
| if _, err := os.Stat(file); os.IsNotExist(err) { | ||
| return nil, clierr.New("no latest role saved", clierr.Info("You can run 'assume' to try and access a role. If the role is inaccessible it will be saved as the latest role.")) | ||
| } | ||
|
|
||
| roleBytes, err := os.ReadFile(file) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| var r Role | ||
| err = json.Unmarshal(roleBytes, &r) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return &r, nil | ||
| } | ||
|
|
||
| type Profile struct { | ||
| Name string | ||
| } | ||
|
|
||
| func (p Profile) Save() error { | ||
| profileBytes, err := json.Marshal(p) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| configFolder, err := config.GrantedConfigFolder() | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| file := filepath.Join(configFolder, "latest-profile") | ||
| return os.WriteFile(file, profileBytes, 0644) | ||
| } | ||
|
|
||
| func LatestProfile() (*Profile, error) { | ||
| configFolder, err := config.GrantedConfigFolder() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| file := filepath.Join(configFolder, "latest-profile") | ||
|
|
||
| if _, err := os.Stat(file); os.IsNotExist(err) { | ||
| return nil, clierr.New("no latest profile saved", clierr.Info("You can run 'assume' to try and access a profile. If the profile is inaccessible it will be saved as the latest profile.")) | ||
| } | ||
|
|
||
| profileBytes, err := os.ReadFile(file) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| var p Profile | ||
| err = json.Unmarshal(profileBytes, &p) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return &p, nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this update checking mechanism works anymore, it would need to be rewritten to point directly at the github releases instead.