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

add token service support for docker registry #14919

Closed
wants to merge 12 commits into from

Conversation

a1012112796
Copy link
Member

@a1012112796 a1012112796 commented Mar 7, 2021

Fix #2316

  • repo name ruler
    <owner>/<repo_name>/<image_name>
  • add a new repo permission unit named as package, it's not a
    real unit in gitea, just use for permission check.
  • add a small api GET /repos/{owner}/{repo}/packages/{type}/{name} for
    test, maybe can add more later

ref:

TODO:
- [ ] handle delete event (can't real delet a repo in docker registry, so this work is not necessary ...)

  • test code

- repo name ruler
  <owner>/<repo_name>[/<image_name>] (note: if `<image_name>` not set,
  will use `<repo_name>` as default)
- add a new repo permission unit named as `package`, it's not a
  real unit in gitea, just use for permission check.
- add a small api `GET /repos/{owner}/{repo}/packages/{type}/{name}` for
  test, maybe can add more later

ref:
- https://docs.docker.com/registry/spec/auth/token/
- https://docs.docker.com/registry/notifications/
- https://github.com/cesanta/docker_auth

Signed-off-by: a1012112796 <1012112796@qq.com>
@a1012112796 a1012112796 added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Mar 7, 2021
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 7, 2021
a1012112796 and others added 6 commits March 8, 2021 15:05
Co-authored-by: techknowlogick <matti@mdranta.net>
because if using token serve, it will be difficut
to use docker registry api directly, try do
someting to simplify it.`

Signed-off-by: a1012112796 <1012112796@qq.com>
modules/structs/package.go Outdated Show resolved Hide resolved
@6543 6543 added this to the 1.15.0 milestone Mar 10, 2021
@a1012112796
Copy link
Member Author

@wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf Thanks for your carefully check

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm 🚀

@lafriks
Copy link
Member

lafriks commented Mar 27, 2021

I was thinking on maybe this could be somehow refactored that this configuration is in database so that it could be extended so that we could have server-wide or per-organization/user docker registry server so that for example I could host my own docker registry server but connect it to external gitea service (like gitea.com or codeberg.org) just for my organization

@techknowlogick
Copy link
Member

@lafriks you could do exactly that currently with https://github.com/cesanta/docker_auth/ (I am the maintainer of that project)

@lunny
Copy link
Member

lunny commented Mar 28, 2021

An alternative to external docker registry integration is necessary because the primary aim of Gitea is to be a package store.

@lafriks
Copy link
Member

lafriks commented Mar 28, 2021

@lafriks you could do exactly that currently with https://github.com/cesanta/docker_auth/ (I am the maintainer of that project)

How this would allow integration with gitea auth?

@a1012112796
Copy link
Member Author

@lafriks you could do exactly that currently with https://github.com/cesanta/docker_auth/ (I am the maintainer of that project)

How this would allow integration with gitea auth?

I know it's steps, It's a littile long.

steps:

    1. user login on doecker auth service by the login link
    1. doecker auth service try to request auth on target sevice (github,gitea...) follow oauth2 ruler
    1. if login success, doecker auth service will generate a token and response it to user
    1. user request JWT token that docker reqistry need by this token from doecker auth service. done.

but user can't used password or api token on gitea or github to request JWT token directly from
doecker auth service ...

@codecov-commenter
Copy link

Codecov Report

Merging #14919 (ff44fca) into master (a3c4c57) will decrease coverage by 0.20%.
The diff coverage is 3.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14919      +/-   ##
==========================================
- Coverage   43.85%   43.64%   -0.21%     
==========================================
  Files         678      686       +8     
  Lines       81503    81966     +463     
==========================================
+ Hits        35741    35775      +34     
- Misses      39971    40400     +429     
  Partials     5791     5791              
Impacted Files Coverage Δ
models/error.go 39.21% <0.00%> (-0.31%) ⬇️
models/package.go 0.00% <0.00%> (ø)
modules/convert/package.go 0.00% <0.00%> (ø)
modules/packages/docker/api.go 0.00% <0.00%> (ø)
modules/packages/docker/auth.go 0.00% <0.00%> (ø)
modules/packages/docker/event_hook.go 0.00% <0.00%> (ø)
routers/api/v1/repo/package.go 0.00% <0.00%> (ø)
routers/repo/package.go 0.00% <0.00%> (ø)
routers/repo/setting.go 13.22% <0.00%> (-0.14%) ⬇️
services/forms/repo_form.go 40.71% <ø> (ø)
... and 31 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a3c4c57...ff44fca. Read the comment docs.

@techknowlogick techknowlogick modified the milestones: 1.15.0, 1.16.0 Jun 23, 2021
@lunny lunny mentioned this pull request Jul 22, 2021
@lunny lunny modified the milestones: 1.16.0, 1.17.0 Nov 9, 2021
@a1012112796 a1012112796 removed this from the 1.17.0 milestone Mar 30, 2022
@a1012112796 a1012112796 deleted the docker_support branch March 30, 2022 14:40
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate or Interface Docker Registry
9 participants