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

WIP: Client API implementation #1119

Closed
wants to merge 39 commits into from
Closed

WIP: Client API implementation #1119

wants to merge 39 commits into from

Conversation

endophage
Copy link
Contributor

Huge feature list here and apologies for the PR bomb.

  • New Interface type defined for client interaction with a repository (client/interface.go)
  • GRPC implementation of the new interface (client_api/api/*)
  • CLI integration with GRPC API if configured (cmd/notary/repo_factory.go and other necessary knock on changes in the cmd/notary package)
  • JWT token auth for the GRPC API consistent with Notary Server and Docker Registry (auth/*). Some of this is to be upstreamed into docker/distribution when I get the chance.
    • If enabled "push" and "pull" actions will always be requested to guarantee the Client API can communicate with the upstream Notary Server to read repos and publish updates. The server configuration will also accept a map of GRPC Endpoint Name : [permissions] (documentation to be written) that allows users to arbitrarily configure in more permissions per GRPC API. Users would need their token server to issue those permissions as appropriate to their users.

Still needed:

  • more tests
  • documentation

Shout out to @n4ss for all the hard work on this. Go get some sleep!

cc @ecordell @lewiada

David Lawrence added 4 commits March 20, 2017 13:59
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
endophage and others added 23 commits March 20, 2017 14:07
Signed-off-by: David Lawrence <dclwrnc@gmail.com> (github: endophage)
…ld be working

Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
…d code

Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: David Lawrence <david.lawrence@docker.com>

Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com> (github: endophage)
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
n4ss and others added 9 commits March 20, 2017 14:08
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
…e. Wrapping up configuration of auth

Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
…r everyone

Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
@endophage endophage changed the title Client API implementation WIP: Client API implementation Mar 20, 2017
…exercise some of the code while I had a debugger running

Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
Copy link
Contributor

@ecordell ecordell left a comment

Choose a reason for hiding this comment

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

This mostly is looking really good! I left some comments from my first pass, I plan to do a more in-depth review soon.

// Notary Interface
service Notary {
// AddTarget adds a target to the TUF repository and re-signs.
rpc AddTarget(TargetAction) returns (BasicResponse) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these take an optional list of roles to sign with? I know the default is to sign with all available, but that might not be the desired behavior when we get to thresholding

gun,
srv.upstream,
rt,
remoteStore, // remote store
Copy link
Contributor

Choose a reason for hiding this comment

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

don't know that this comment is adding much :)


type repoFactory func(gun data.GUN) (client.Repository, error)

func ConfigureRepo(v *viper.Viper, retriever notary.PassRetriever, onlineOperation bool) repoFactory {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 this really cleans things up

@@ -0,0 +1,215 @@
package token
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 for a dependency removed

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'm actually going to try and upstream these auth pieces back into distribution. I don't particularly want a forked version I have to keep up to date if somebody changes something. The version in docker/distribution is basically the canonical version for Docker but it was too tightly coupled with net/http and I needed to make progress.


const remoteConfigField = "api"

type repoFactory func(gun data.GUN) (client.Repository, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the naming here could be confusing, because RepoBuilder already exists. Maybe more explicitly clientRepoFactory? (same for filename as well)

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 have some stuff to discuss at our maintainers meeting at DockerCon that may obsolete RepoBuilder :-)

offlineAccess: false,
forceOAuth: false,
clientID: clientID,
//scopes: []Scope{
Copy link
Contributor

Choose a reason for hiding this comment

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

these comments should be cleaned up

return fmt.Sprintf("%s:%s:%s", repoType, rs.Repository, strings.Join(rs.Actions, ","))
}

//// RegistryScope represents a token scope for access
Copy link
Contributor

Choose a reason for hiding this comment

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

if this is unused it should be removed

}

func (th *TokenHandler) AuthorizeRequest(params map[string]string, scopes ...string) (string, error) {
//th.tokenLock.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

remove these? can't think of a reason there would need to be a lock here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a token cache (map[something]something) I removed that this was locking.

); err != nil {
return nil, err
}
if err := publishRepo(r); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the responsibility to publish be pushed back to the "clientapi client" instead of in the "clientapi server"?

IIRC this mirrors the current cli behavior, just wondering if there's a good reason to keep them coupled together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the case where somebody horizontally scales Client API's (I'm just using that as the name for this new service), there's no guarantee you'll hit the same instance again. I think it's a lot cleaner and easier to implement if every operation is a one shot that publishes (where appropriate, we intend to support things like letting clients add keys, which would still require some kind of synchronization between instances).

return nil, err
}

resTargets := make([]*TargetWithRole, len(targets))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these be factored out? Maybe something like NewTargetWithRole(Target) and NewTargetWithRoles([]Target)

They only really need to be serialized here so I understand not separating it out, but if they were separate it would be very clear that all this server does is proxy commands to a repo object and then serialize the results.

(Same comment for all of the other serialization happening in this file)

David Lawrence added 2 commits March 30, 2017 10:39
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
@endophage
Copy link
Contributor Author

Superseded by #1139

@endophage endophage closed this Apr 25, 2017
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.

4 participants