Skip to content
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

storage: make static storages query real storages for some actions #855

Merged
merged 1 commit into from
Mar 20, 2017

Conversation

ericchiang
Copy link
Contributor

If dex is configured with static passwords or clients, let the API
still add or modify objects in the backing storage, so long as
their IDs don't conflict with the static ones. List options now
aggregate resources from the static list and backing storage.

Closes #735

Still needs unit tests.

@ericchiang ericchiang force-pushed the static-storage-fallthrough branch 3 times, most recently from a6caa69 to 2bbf996 Compare March 16, 2017 23:18
}

func (s staticClientsStorage) CreateClient(c Client) error {
return errors.New("static clients: read-only cannot create client")
if s.isStatic(c.ID) {
return errors.New("static clients: read-only cannot create client")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we show a different error message that implies that the client already exists as a static client? Similar comment for CreatePassword

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like adding yet another sentinel error :( Maybe we could introduce a storage.Error interface instead? Something like

type ErrKind int

const (
    ErrAlreadyExists ErrKind = iota
    ErrNotFound
    ErrNotModifiable
    ErrUnknown
)

type Error interface {
    Kind() ErrKind
}

Then use that to do all of this custom detection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice article on these kind of errors here: https://dave.cheney.net/2014/12/24/inspecting-errors

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep that would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something we want to address in this PR or later? I'm leaning towards later.

Copy link
Contributor

@rithujohn191 rithujohn191 Mar 17, 2017

Choose a reason for hiding this comment

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

ok we could address it separately

s2 := storage.WithStaticClients(s, []storage.Client{c2})
c3 := storage.Client{ID: "spam", Secret: "spam_secret"}

backing.CreateClient(c1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to add a similar test for Passwords?

If dex is configured with static passwords or clients, let the API
still add or modify objects in the backing storage, so long as
their IDs don't conflict with the static ones. List options now
aggregate resources from the static list and backing storage.
Copy link
Contributor

@rithujohn191 rithujohn191 left a comment

Choose a reason for hiding this comment

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

lgtm. Thanks for the test.

@ericchiang ericchiang merged commit 95d2370 into dexidp:master Mar 20, 2017
@ericchiang ericchiang deleted the static-storage-fallthrough branch March 20, 2017 17:42
mmrath pushed a commit to mmrath/dex that referenced this pull request Sep 2, 2019
storage: make static storages query real storages for some actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants