Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

immich-go appears to retain/cache an API key #214

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions cmd/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,14 @@ func (app *SharedFlags) Start(ctx context.Context) error {

// If the client isn't yet initialized
if app.Immich == nil {
conf, err := configuration.Read(app.ConfigurationFile)
confExist := err == nil
if confExist && app.Server == "" && app.Key == "" && app.API == "" {
app.Server = conf.ServerURL
app.Key = conf.APIKey
app.API = conf.APIURL
if app.Server == "" && app.API == "" && app.Key == "" {
conf, err := configuration.Read(app.ConfigurationFile)
confExist := err == nil
if confExist && app.Server == "" && app.Key == "" && app.API == "" {
app.Server = conf.ServerURL
app.Key = conf.APIKey
app.API = conf.APIURL
}
}

switch {
Expand All @@ -125,10 +127,12 @@ func (app *SharedFlags) Start(ctx context.Context) error {
}

// Connection details are saved into the configuration file
conf.ServerURL = app.Server
conf.APIKey = app.Key
conf.APIURL = app.API
err = conf.Write(app.ConfigurationFile)
conf := configuration.Configuration{
ServerURL: app.Server,
APIKey: app.Key,
APIURL: app.API,
}
err := conf.Write(app.ConfigurationFile)
if err != nil {
err = fmt.Errorf("can't write into the configuration file: %w", err)
joinedErr = errors.Join(joinedErr, err)
Expand Down
16 changes: 6 additions & 10 deletions docs/releases.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# Release notes

## Release 0.13.1

### Improvement: [#195](https://github.com/simulot/immich-go/issues/195) Rethink the user interactions with the CLI application #195

#### Use Bubble Tea library to provide a modern TUI (Terminal User Interface)


### API KEY self provisioning
When the server and the API keys aren't given on the command line, immich-go ask the user if he wants to get a key from a server, and saves it the configuration file.
## Release 0.13.0

### Fix [#199](https://github.com/simulot/immich-go/issues/199)
### Fix [[#211](https://github.com/simulot/immich-go/issues/211)] immich-go appears to retain/cache an API key
Fix the logic for retaining the credential:

When given, the credentials are saved into the configuration file.
When not given, the credential are read from the configuration file if possible.

## Release 0.13.0

### Improvement: [#189](https://github.com/simulot/immich-go/issues/189) Use a configuration file to store server's address and its API key
Expand Down
Loading