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

Allow http(s) git actions using application token #842

Closed
compressed opened this issue Jan 7, 2015 · 32 comments
Closed

Allow http(s) git actions using application token #842

compressed opened this issue Jan 7, 2015 · 32 comments
Labels
🎯 feature Categorizes as related to a new feature status: needs feedback Tell me more about it

Comments

@compressed
Copy link
Contributor

I was wondering if we can use the application token that a user has created to also permit git actions to repos the user has access to.

This is useful when it's needed to programmatically push commits to a repo.

GitHub allows this via the following:

git push https://${GITHUB_TOKEN}@github.com/user/repo.git

Edit: It would be best if the token works for the gamut of git actions: e.g. pull, push, clone, etc.

@compressed compressed changed the title Allow http(s) git push using application token Allow http(s) git actions using application token Jan 7, 2015
@unknwon
Copy link
Member

unknwon commented Jan 7, 2015

Will Git converts ${GITHUB_TOKEN} to request header automatically?

@compressed
Copy link
Contributor Author

I don't think so. We probably need to add some logic in gogs that if we don't find the username, check if the username is actually a token.

Some more info here: https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth

@unknwon
Copy link
Member

unknwon commented Jan 7, 2015

I want to say that Go looks like cannot get content before @, and it doesn't even say user is using HTTP or HTTPS in *http.Request.

But,

check if the username is actually a token.

I think it would work. 👍

@unknwon unknwon added the 🎯 feature Categorizes as related to a new feature label Jan 7, 2015
compressed added a commit to compressed/gogs that referenced this issue Jan 8, 2015
compressed added a commit to compressed/gogs that referenced this issue Jan 8, 2015
compressed added a commit to compressed/gogs that referenced this issue Jan 8, 2015
unknwon added a commit that referenced this issue Feb 7, 2015
@unknwon unknwon added the status: needs feedback Tell me more about it label Feb 7, 2015
@unknwon
Copy link
Member

unknwon commented Feb 7, 2015

Hi @compressed , thanks for waiting. I've pushed some fixes based on changes you made on #845 . You are also free to try on https://try.gogs.io/

@unknwon
Copy link
Member

unknwon commented Feb 13, 2015

As new mirror release v0.5.13 is going to release, and this issue is labeled as feedback needed, so close it for assumed resolved, feel free to reopen this if you want to continue discussing. 🍺

@unknwon unknwon closed this as completed Feb 13, 2015
@lavvy
Copy link

lavvy commented Sep 1, 2015

Please has this feature being added ? Please how do I learn more how to use it to pull .tar from my private repository

@unknwon
Copy link
Member

unknwon commented Sep 1, 2015

@lavvy this was implemented a while ago, based on the code, yes, it has added.

@lavvy
Copy link

lavvy commented Sep 1, 2015

Oh cool. So I am cloning into Jenkins with this url when it's public repo
https://try.gogs.io/lavvy/newproj

And I download tar file with this url
https://try.gogs.io/lavvy/newproj/archive/master.tar.gz

So if it now private repo, how will the urls be ?
On Sep 1, 2015 12:03 PM, "无闻" notifications@github.com wrote:

@lavvy https://github.com/lavvy this was implemented a while ago, based
on the code, yes, it has added.


Reply to this email directly or view it on GitHub
#842 (comment).

@unknwon
Copy link
Member

unknwon commented Sep 1, 2015

@lavvy it is exactly same URL, except you have to be logged in.

@unknwon
Copy link
Member

unknwon commented Sep 1, 2015

You use curl with basic auth through HTTP.

@lavvy
Copy link

lavvy commented Sep 1, 2015

Yeah I mean assessing it from a url for instance Jenkins will access it as
an application. Then if I want to do wget command from Linux , how will the
url be
On Sep 1, 2015 2:13 PM, "无闻" notifications@github.com wrote:

You use curl with basic auth through HTTP.


Reply to this email directly or view it on GitHub
#842 (comment).

@lavvy
Copy link

lavvy commented Sep 1, 2015

And then how to generate the token for a repo. I couldn't just see how
On Sep 1, 2015 2:13 PM, "无闻" notifications@github.com wrote:

You use curl with basic auth through HTTP.


Reply to this email directly or view it on GitHub
#842 (comment).

@unknwon
Copy link
Member

unknwon commented Sep 1, 2015

Yeah I mean assessing it from a url for instance Jenkins will access it as
an application. Then if I want to do wget command from Linux , how will the
url be

wget https://try.gogs.io/lavvy/newproj/archive/master.tar.gz

And then how to generate the token for a repo. I couldn't just see how

There is no such that token for a repo, only token for a user

@lavvy
Copy link

lavvy commented Sep 1, 2015

sorry for my english may be we are missing something here.

please reproduce this please here
if you click this
https://try.gogs.io/lavvy/newproj/archive/master.tar.gz
you will download the tar file because that is a PUBLIC repo

BUT :

if you click this
https://try.gogs.io/lavvy/bogons/archive/master.tar.gz

you CANNOT download the tar file because it is a PRIVATE repo

NOW:
my question is
HOW do i insert my token in the second url so that i can download the tar file ?
(REMEMBER I AM ASSESSING WITHOUT A BROWSER THEREFORE I CANNOT LOG IN)

I TRIED THIS
https://try.gogs.io//bogons/archive/master.tar.gz
BUT IT DIDNT WORK

On 9/1/15, 无闻 notifications@github.com wrote:

Yeah I mean assessing it from a url for instance Jenkins will access it
as
an application. Then if I want to do wget command from Linux , how will the
url be

wget https://try.gogs.io/lavvy/newproj/archive/master.tar.gz

And then how to generate the token for a repo. I couldn't just see how

There is no such that token for a repo, only token for a user


Reply to this email directly or view it on GitHub:
#842 (comment)

@lavvy
Copy link

lavvy commented Sep 1, 2015

Please any docs on how to do this please
On Sep 1, 2015 2:48 PM, "Uche Okonkwo" lavashonline@gmail.com wrote:

sorry for my english may be we are missing something here.

please reproduce this please here
if you click this
https://try.gogs.io/lavvy/newproj/archive/master.tar.gz
you will download the tar file because that is a PUBLIC repo

BUT :

if you click this
https://try.gogs.io/lavvy/bogons/archive/master.tar.gz

you CANNOT download the tar file because it is a PRIVATE repo

NOW:
my question is
HOW do i insert my token in the second url so that i can download the tar
file ?
(REMEMBER I AM ASSESSING WITHOUT A BROWSER THEREFORE I CANNOT LOG IN)

I TRIED THIS
https://try.gogs.io//bogons/archive/master.tar.gz
BUT IT DIDNT WORK

On 9/1/15, 无闻 notifications@github.com wrote:

Yeah I mean assessing it from a url for instance Jenkins will access it
as
an application. Then if I want to do wget command from Linux , how will
the
url be

wget https://try.gogs.io/lavvy/newproj/archive/master.tar.gz

And then how to generate the token for a repo. I couldn't just see how

There is no such that token for a repo, only token for a user


Reply to this email directly or view it on GitHub:
#842 (comment)

@unknwon
Copy link
Member

unknwon commented Sep 1, 2015

@lavvy well.. I've said you can use basic auth through HTTP(it's not a topic of Gogs, it's HTTP standard)...

@lavvy
Copy link

lavvy commented Sep 1, 2015

you mean like this ?

https://try.gogs.io/lavvy/bogons/archive/master.tar.gz?token=usertoken

On 9/1/15, 无闻 notifications@github.com wrote:

@lavvy well.. I've said you can use basic auth through HTTP...


Reply to this email directly or view it on GitHub:
#842 (comment)

@unknwon
Copy link
Member

unknwon commented Sep 1, 2015

I just don't understand why a Google search is so hard... https://docs.oracle.com/cd/E24191_01/common/tutorials/authn_http_basic.html

@lavvy
Copy link

lavvy commented Sep 1, 2015

@unknown, am sorry for stressing you out , but please pardon me , i
just discovered this software. And it looks like its relatively new
and quite promising.
Pardon that i couldnt have seen so much of its docs. we are looking to
start using it especially for the private repo feature.
what i am asking for is relatively very simple, i dont know why its
taking this long.
Look at how we get zips or tarballs from private repos from other scm
apps in ubuntu linux command line, for instance;

IN GITHUB :
wget --output-document=.tar.gz
https://api.github.com/repos///tarball/?access_token=

IN GITLAB:
wget https://gitlab.com/api/v3/projects/<project_id>/repository/raw_blobs/<file_id>?private_token=<your_private_token>

IN BITBUCKET :
wget https://bytebucket.org/$username/$repo/raw/$sha/$filename.jpg?token=$sometoken

IN GOGS ;
(please just give me an example url here:
wget________________________________________________________ please )

once again thank you guys for the beautiful job you guys are doing right there

On 9/1/15, Uche Okonkwo lavashonline@gmail.com wrote:

you mean like this ?

https://try.gogs.io/lavvy/bogons/archive/master.tar.gz?token=usertoken

On 9/1/15, 无闻 notifications@github.com wrote:

@lavvy well.. I've said you can use basic auth through HTTP...


Reply to this email directly or view it on GitHub:
#842 (comment)

@vijairaj
Copy link

vijairaj commented Sep 2, 2015

I took some time to test this functionality. I see that it works for git commands, eg:

git clone https://e6503db88f1db7018747fedffd8f3296ce3a01b1@try.gogs.io/u99/pr1

But not for all URLs, for example the below doesn't work:

wget https://e6503db88f1db7018747fedffd8f3296ce3a01b1@try.gogs.io/u99/pr1/archive/master.tar.gz

@unknwon
Copy link
Member

unknwon commented Sep 2, 2015

@lavvy OK. Sorry for poor docs...

I just added allow URL query to pass token value like all of your 3 examples in develop branch, and have updated https://try.gogs.io .

So in your example you need to download a raw blob, here is the example from my local server:

wget http://localhost:3000/api/v1/repos/unknwon/macaron/raw/master/README.md\?token\=7ba8bcfb08c9ca128e475d098b42a815e8ddd5d9

The basic format it:

wget {HOST}/api/v1/repos/{username}/{reponame}/raw/{ref}/{blob path}?token={token}

@lavvy
Copy link

lavvy commented Sep 2, 2015

yeah, thats what i meant . @unknown it now works like charm but i
tried adjusting the string to download a full release like
v0.0.1.tar.gz or master.tar.gz , it didnt work. please could you
support that too, i think it will use the same pattern

meanwhile thanks @vijairaj,

On 9/2/15, 无闻 notifications@github.com wrote:

@lavvy OK. Sorry for poor docs...

I just added allow URL query to pass token value like all of your 3 examples
in develop branch, and have updated https://try.gogs.io .

So in your example you need to download a raw blob, here is the example from
my local server:

wget
http://localhost:3000/api/v1/repos/unknwon/macaron/raw/master/README.md\?token\=7ba8bcfb08c9ca128e475d098b42a815e8ddd5d9

The basic format it:

wget {HOST}/api/v1/repos/{username}/{reponame}/raw/{ref}/{blob
path}?token={token}

Reply to this email directly or view it on GitHub:
#842 (comment)

@unknwon
Copy link
Member

unknwon commented Sep 2, 2015

@lavvy yeah, OK, let me see.

@unknwon
Copy link
Member

unknwon commented Sep 2, 2015

OK, on develop and try.gogs.io, you can use following format to download archive:

wget {HOST}/api/v1/repos/{username}/{reponame}/archive/{ref}.{format}?token={token}

example

wget https://try.gogs.io/api/v1/repos/unknwon/macaron/archive/4d7e15f9cb3e636ae685efdee690b6f0b0f2e17a.tar.gz?token=xxx

@lavvy
Copy link

lavvy commented Sep 2, 2015

Pure. So Pure. thumbs up man. this is good so far and keep up the good
work. Maybe i will have to close back the issue and let the sleeping
dog lie.

On 9/2/15, 无闻 notifications@github.com wrote:

OK, on develop and try.gogs.io, you can use following format to download
archive:

wget
{HOST}/api/v1/repos/{username}/{reponame}/archive/{ref}.{format}?token={token}

example

wget
https://try.gogs.io/api/v1/repos/unknwon/macaron/archive/4d7e15f9cb3e636ae685efdee690b6f0b0f2e17a.tar.gz?token=xxx

Reply to this email directly or view it on GitHub:
#842 (comment)

@unknwon
Copy link
Member

unknwon commented Sep 2, 2015

@lavvy 😉

@lavvy
Copy link

lavvy commented Sep 2, 2015

yeah, real good feature right there @unknwon , but it wasnt easy . you remember u almost gave up yesterday, but u didn't and thats how great guys are born. 👍

@lavvy
Copy link

lavvy commented May 4, 2016

Please, looks like this feature is broken or removed or changed . It doesn't work again.
Please is there a different format to download a versioned release from a private repo.

@klappy
Copy link

klappy commented May 18, 2017

We are attempting to use token based git pushes so that we don't have to send passwords. Does anybody have any tips on using this with git actions such as pushing to gogs?

@unknwon
Copy link
Member

unknwon commented May 19, 2017

@klappy I think use access token as username with empty password should work already.

@erguotou520
Copy link

So how do I push throw token?

git push -u https://gogs.erguotou.me/erguotou/gift-pwa.git?token=token master --force

like this?

@unknwon
Copy link
Member

unknwon commented Jul 14, 2017

@erguotou520 no, use token ad username when Git prompts you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🎯 feature Categorizes as related to a new feature status: needs feedback Tell me more about it
Projects
None yet
Development

No branches or pull requests

6 participants