Skip to content

Conversation

cveticm
Copy link
Collaborator

@cveticm cveticm commented Sep 8, 2025

Proposed changes

Config describe should print secure properties (public_api_key,private_api_key, etc.) with value redacted.

How it works

  • Create a new Store (configStore) without reading in env vars
  • Get a map of all the insecurely stored profile properties using configStore
  • For all secure properties, get the property value using configStore and include it in the map with value redacted
    • No additional logic is needed if the secure property is held insecurely or securely. configStore will call to the appropriate place. And, as configStore does not take into account env vars, these will not cause any trouble either.

Design decisions

  1. Checking for all secure properties, despite the set auth_type
    If a user has managed to configure their profile in a way that it has multiple authentication type credentials, this should be reflected in config describe to easier help the user diagnose any auth issues this might cause

  2. Redacted text
    To make clear to the user where a secure property is being held, the redacted text includes its source:
    [redacted - source: secure storage]
    [redacted - source: config file]

example output:

// before - secure properties not shown at all
bin/atlas config describe sa   
SETTING           VALUE
auth_type         service_account
org_id            670cd17af33cea212ea1ed61
output            plaintext
project_id        670e34d35a4f587387db2102
service           cloud

//after - secure properties show but redacted
bin/atlas config describe sa   
SETTING           VALUE
auth_type         service_account
client_id         [redacted - source: secure storage]
client_secret     [redacted - source: secure storage]
org_id            670cd17af33cea212ea1ed61
output            plaintext
project_id        670e34d35a4f587387db2102
service           cloud

@cveticm cveticm requested a review from a team as a code owner September 8, 2025 10:20

// AddSecureProperties adds secure properties to the map with "redacted" value
// if they are available in the config.
func (opts *describeOpts) AddSecureProperties(m map[string]string) (map[string]string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] is there a way can we expand this on atlas config edit since that one opens the config file? cc @jeroenvervaeke

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the code, atlas config edit opens the actual config file (with vi or similar). We'd have to entirely refactor how the command works to support this.

Copy link
Collaborator

@blva blva Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the tradeoff of adding it at the config level, having to re-add the redacted values. I found myself confused before when trying to find out if my credentials were correct or not and saw that it was not in the file at atlas config edit.

I'm good with this change anyways since it fixes config describe but I think we should probably discuss if we're happy to keep atlas config edit as is or not in the team channel

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on discussing if followup work is needed for config edit 👍

I think we could change the command to

  1. Open a copy of the config file that we populate with redacted secure properties.
  2. When a user is finished, we'd run the migration logic on the file and replace the actual config with the copy.

This is just the first solution that came to mind, happy to discuss more with the team tomorrow during sync

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep if we have a list of options that would be awesome to chat w/ the team async, my stamp is 🚢 anyways

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should alter atlas config edit, since the secrets are not saved in the config I don't think we should re-add them and say [redacted].

I think that approach will make things even more confusing and give customers the impression that our credentials are stored in the config, which is not true.

@coveralls
Copy link
Collaborator

coveralls commented Sep 8, 2025

Coverage Status

coverage: 63.961% (+0.01%) from 63.948%
when pulling 9b360da on fix_describe_secure_properties
into feaebe1 on master.

blva
blva previously approved these changes Sep 8, 2025
if err != nil {
return nil, err
}
if !configStore.IsSecure() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] When we use the insecure store, we still want to redact the secrets. No?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already done by the function config.Map(), see here


// AddSecureProperties adds secure properties to the map with "redacted" value
// if they are available in the config.
func (opts *describeOpts) AddSecureProperties(m map[string]string) (map[string]string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this entire function be written as follows?

func (opts *describeOpts) AddSecureProperties(m map[string]string, ctx context.Context) (map[string]string, error) {
	for _, key := range config.SecureProperties {
		if v, found := m[key]; found && v != "" {
			m[key] = redacted
		}
	}

	return m, nil
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Map m is only the values in config.toml. Thus we have to populate the map with the additional properties held in secure storage.

@cveticm cveticm force-pushed the fix_describe_secure_properties branch from 5bba97a to bb14bbe Compare September 9, 2025 10:15
@cveticm cveticm marked this pull request as draft September 9, 2025 10:42
@cveticm cveticm force-pushed the fix_describe_secure_properties branch from 6955a70 to 9b360da Compare September 9, 2025 12:06
@cveticm cveticm marked this pull request as ready for review September 9, 2025 12:28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for increasing the test coverage 🙏

@cveticm cveticm merged commit e223f72 into master Sep 9, 2025
47 of 49 checks passed
@cveticm cveticm deleted the fix_describe_secure_properties branch September 9, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants