Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit a248df3

Browse files
authored
Allow caching authentication identifiers provided in the login command (#40)
* Allow caching authentication identifiers provided in the login command * Update submodule branch to main * Add change log file
1 parent ad5de93 commit a248df3

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @calebkiage @baywet @zengin @MichaelMainer @andrueastman @peombwa @jobala @samwelkanda
1+
* @calebkiage @baywet @zengin @MichaelMainer @andrueastman @peombwa @samwelkanda

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Added support for JMESPath queries #35
13+
- Added clientId and tenantId parameters to the login command #40
14+
15+
### Changed
16+
17+
- Fixed bug caused by URL path parameters not being set in the request information object #38
18+
- Fixed stream output being passed to output formatter when no file path is provided #38

src/Program.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static async Task<int> Main(string[] args)
4242
ConfigureAppConfiguration(configBuilder);
4343
var config = configBuilder.Build();
4444

45-
var authSettings = config.GetSection(Constants.AuthenticationSection).Get<AuthenticationOptions>();
45+
var authSettings = config.GetSection(nameof(AuthenticationOptions)).Get<AuthenticationOptions>();
4646
var authServiceFactory = new AuthenticationServiceFactory(new PathUtility());
4747
var authStrategy = AuthenticationStrategy.DeviceCode;
4848

@@ -125,9 +125,10 @@ static IHostBuilder CreateHostBuilder(string[] args) =>
125125
}).ConfigureAppConfiguration((ctx, config) => {
126126
ConfigureAppConfiguration(config);
127127
}).ConfigureServices((ctx, services) => {
128-
var authSection = ctx.Configuration.GetSection(Constants.AuthenticationSection);
128+
var authSection = ctx.Configuration.GetSection(nameof(AuthenticationOptions));
129129
services.Configure<AuthenticationOptions>(authSection);
130130
services.AddSingleton<IPathUtility, PathUtility>();
131+
services.AddSingleton<IAuthenticationCacheUtility, AuthenticationCacheUtility>();
131132
services.AddSingleton<IOutputFilter, JmesPathOutputFilter>();
132133
services.AddSingleton<JmesPath>();
133134
services.AddSingleton<IOutputFormatterFactory, OutputFormatterFactory>();
@@ -136,9 +137,12 @@ static IHostBuilder CreateHostBuilder(string[] args) =>
136137
static void ConfigureAppConfiguration(IConfigurationBuilder builder) {
137138
builder.Sources.Clear();
138139
builder.AddJsonFile("app-settings.json", optional: false);
139-
var dataDir = new PathUtility().GetApplicationDataDirectory();
140+
var pathUtil = new PathUtility();
141+
var authCache = new AuthenticationCacheUtility(pathUtil);
142+
var dataDir = pathUtil.GetApplicationDataDirectory();
140143
var userConfigPath = Path.Combine(dataDir, "settings.json");
141144
builder.AddJsonFile(userConfigPath, optional: true);
145+
builder.AddJsonFile(authCache.GetAuthenticationCacheFilePath(), optional: true, reloadOnChange: true);
142146
builder.AddEnvironmentVariables(prefix: "MGC_");
143147
}
144148
}

src/app-settings.sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Authentication": {
2+
"AuthenticationOptions": {
33
"ClientId": "client id",
44
"TenantId": "tenant id"
55
}

0 commit comments

Comments
 (0)