최신판 |
당신의 편집 |
167번째 줄: |
167번째 줄: |
| // success, do something | | // success, do something |
| </syntaxhighlight>웹훅 리스트에서 들어가면 "전달 시험" 버튼이 있다. | | </syntaxhighlight>웹훅 리스트에서 들어가면 "전달 시험" 버튼이 있다. |
− |
| |
− | == 개발자 ==
| |
− |
| |
− | === API ===
| |
− |
| |
− | ==== API 접근 활성화/설정 ====
| |
− | 기본적으로 <code>ENABLE_SWAGGER</code>는 true이고, <code>MAX_RESPONSE_ITEMS</code>는 50으로 설정되어 있다.
| |
− |
| |
− | ==== 인증 ====
| |
− | Gitea는 API인증에 다음 methods를 제공한다.
| |
− |
| |
− | * HTTP basic authentication
| |
− | * <code>token=...</code> parameter in URL query string
| |
− | * <code>access_token=...</code> parameter in URL query string
| |
− | * <code>Authorization: token ...</code> header in HTTP headers
| |
− |
| |
− | 모든 methods는 같은 API key token type을 수락한다. Gitea는 modules/auth/auth.go에서 그 토큰을 찾기 위해 querys와 headers를 파싱한다. 코드를 봐야 이해하기가 낫다.
| |
− |
| |
− | ==== 생성과 API tokens 리스팅 ====
| |
− | 웹 페이지 사용자 설정에서 "어플리케이션"에 "토큰 생성"이 있다.
| |
− |
| |
− | 혹은 새로운 토큰은 <code>/users/:name/tokens</code>에 POST요청으로 생성할 수 있다.
| |
− |
| |
− | <code>/users/:name/tokens</code>는 특별한 endpoint이고 <code>BasicAuth</code>와 비밀번호를 사용해서 인증해야 한다.<syntaxhighlight lang="bash">
| |
− | $ curl -XPOST -H "Content-Type: application/json" -k -d '{"name":"test"}' -u username:password https://gitea.your.host/api/v1/users/<username>/tokens
| |
− | {"id":1,"name":"test","sha1":"9fcb1158165773dd010fca5f0cf7174316c3e37d","token_last_eight":"16c3e37d"}
| |
− | </syntaxhighlight>( sha1토큰)은 한 번만 반환되며 일반 텍스트로 저장되지 않습니다. GET 요청이 있는 토큰을 나열할 때 표시되지 않습니다 .<syntaxhighlight lang="bash">
| |
− | $ curl --request GET --url https://yourusername:password@gitea.your.host/api/v1/users/<username>/tokens
| |
− | [{"name":"test","sha1":"","token_last_eight:"........":},{"name":"dev","sha1":"","token_last_eight":"........"}]
| |
− | </syntaxhighlight>기본 인증을 사용하기 위해서는 two factor 인증이 활성화되어 있어야 하고 one time password가 포함된 헤더를 추가로 보내야 한다. <syntaxhighlight lang="bash">
| |
− | $ curl -H "X-Gitea-OTP: 123456" --request GET --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens
| |
− | </syntaxhighlight>
| |
− |
| |
− | ==== OAuth2 Provider ====
| |
− |
| |
− | ===== Authorization =====
| |
− |
| |
− | ==== API 가이드 ====
| |
− | API Reference 가이드는 swagger에 의해 자동으로 생성된다.
| |
− |
| |
− | <nowiki>https://gitea.your.host/api/swagger</nowiki> 나 [https://try.gitea.io/api/swagger Gitea demo instance] 에서 볼 수 있다.
| |
− |
| |
− | ==== Sudo ====
| |
− | <code>sudo=</code> 파라미터나(GET방식) <code>Sudo:</code> 요청 헤더를 username과 함께 추가해라.
| |
− |
| |
− | ==== SDKs ====
| |
− |
| |
− | * [https://gitea.com/gitea/go-sdk Official go-sdk]
| |
− |
| |
| [[분류:프로그래밍]] | | [[분류:프로그래밍]] |
| [[분류:Web server]] | | [[분류:Web server]] |