forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/go-gitea/gitea
- Loading branch information
Showing
114 changed files
with
2,465 additions
and
1,350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> | ||
<service_bundle type="manifest" name="export"> | ||
<service name="gitea" type="service" version="1"> | ||
<create_default_instance enabled="false"/> | ||
|
||
<dependency name="network" grouping="require_all" restart_on="refresh" type="service"> | ||
<service_fmri value="svc:/milestone/network:default"/> | ||
</dependency> | ||
|
||
<dependency name="filesystem" grouping="require_all" restart_on="refresh" type="service"> | ||
<service_fmri value="svc:/system/filesystem/local"/> | ||
</dependency> | ||
|
||
<exec_method | ||
type="method" | ||
name="start" | ||
exec="/opt/local/bin/gitea web" | ||
timeout_seconds="60"> | ||
<method_context> | ||
<method_credential user="git" group="git" /> | ||
<method_environment> | ||
<envvar name='GITEA_WORK_DIR' value='/opt/local/share/gitea'/> | ||
<envvar name='GITEA_CUSTOM' value='/opt/local/etc/gitea'/> | ||
<envvar name='HOME' value='/var/db/gitea'/> | ||
<envvar name='PATH' value='/opt/local/bin:${PATH}'/> | ||
<envvar name='USER' value='git'/> | ||
</method_environment> | ||
</method_context> | ||
</exec_method> | ||
<exec_method type="method" name="stop" exec=":kill" timeout_seconds="60"/> | ||
|
||
<property_group name="application" type="application"></property_group> | ||
<property_group name="startd" type="framework"> | ||
<propval name="duration" type="astring" value="child"/> | ||
<propval name="ignore_error" type="astring" value="core,signal"/> | ||
</property_group> | ||
|
||
<template> | ||
<common_name> | ||
<loctext xml:lang="C">A painless, self-hosted Git service</loctext> | ||
</common_name> | ||
</template> | ||
|
||
</service> | ||
</service_bundle> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
date: "2018-06-24:00:00+02:00" | ||
title: "API Usage" | ||
slug: "api-usage" | ||
weight: 40 | ||
toc: true | ||
draft: false | ||
menu: | ||
sidebar: | ||
parent: "advanced" | ||
name: "API Usage" | ||
weight: 40 | ||
identifier: "api-usage" | ||
--- | ||
|
||
# Gitea API Usage | ||
|
||
## Enabling/configuring API access | ||
|
||
By default, `ENABLE_SWAGGER_ENDPOINT` is true, and | ||
`MAX_RESPONSE_ITEMS` is set to 50. See [Config Cheat | ||
Sheet](https://docs.gitea.io/en-us/config-cheat-sheet/) for more | ||
information. | ||
|
||
## Authentication via the API | ||
|
||
Gitea supports these methods of API authentication: | ||
|
||
- HTTP basic authentication | ||
- `token=...` parameter in URL query string | ||
- `access_token=...` parameter in URL query string | ||
- `Authorization: token ...` header in HTTP headers | ||
|
||
All of these methods accept the same apiKey token type. You can | ||
better understand this by looking at the code -- as of this writing, | ||
Gitea parses queries and headers to find the token in | ||
[modules/auth/auth.go](https://github.com/go-gitea/gitea/blob/6efdcaed86565c91a3dc77631372a9cc45a58e89/modules/auth/auth.go#L47). | ||
|
||
You can create an apiKey token via your gitea install's web interface: | ||
`Settings | Applications | Generate New Token`. | ||
|
||
### More on the `Authorization:` header | ||
|
||
For historical reasons, Gitea needs the word `token` included before | ||
the apiKey token in an authorization header, like this: | ||
|
||
``` | ||
Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675 | ||
``` | ||
|
||
In a `curl` command, for instance, this would look like: | ||
|
||
``` | ||
curl -X POST "http://localhost:4000/api/v1/repos/test1/test1/issues" \ | ||
-H "accept: application/json" \ | ||
-H "Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675" \ | ||
-H "Content-Type: application/json" -d "{ \"body\": \"testing\", \"title\": \"test 20\"}" -i | ||
``` | ||
|
||
As mentioned above, the token used is the same one you would use in | ||
the `token=` string in a GET request. | ||
|
||
## Listing your issued tokens via the API | ||
|
||
As mentioned in | ||
[#3842](https://github.com/go-gitea/gitea/issues/3842#issuecomment-397743346), | ||
`/users/:name/tokens` is special and requires you to authenticate | ||
using BasicAuth, as follows: | ||
|
||
### Using basic authentication: | ||
|
||
``` | ||
$ curl --request GET --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens | ||
[{"name":"test","sha1":"..."},{"name":"dev","sha1":"..."}] | ||
``` |
Oops, something went wrong.