Skip to content

Commit

Permalink
wipes profile section when bmx write --use-credential-process is ran (#…
Browse files Browse the repository at this point in the history
…447)

### Why
If there's a profile with the same name in the credentials and config
file, it will default to the credentials file, so you will eventually
get invalid credentials


### Ticket
https://desire2learn.atlassian.net/browse/VUL-329

---------

Co-authored-by: DotNet Format Bot <[email protected]>
  • Loading branch information
jkomonen and DotNet Format Bot authored Jun 6, 2024
1 parent 919c355 commit d64951a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/D2L.Bmx/WriteHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ bool useCredentialProcess
if( !data.Sections.ContainsSection( sectionName ) ) {
data.Sections.AddSection( sectionName );
}
if( File.Exists( SharedCredentialsFile.DefaultFilePath ) ) {
var defaultCredentialsFile = parser.ReadFile( SharedCredentialsFile.DefaultFilePath );
if( defaultCredentialsFile.Sections.ContainsSection( profile ) ) {
defaultCredentialsFile.Sections.RemoveSection( profile );
parser.WriteFile( SharedCredentialsFile.DefaultFilePath, defaultCredentialsFile );
}
}
data[sectionName]["credential_process"] =
"bmx print --format json --cache --non-interactive"
+ $" --org \"{oktaApi.Org}\""
Expand Down

0 comments on commit d64951a

Please sign in to comment.