aboutsummaryrefslogtreecommitdiffstats
path: root/routers
Commit message (Collapse)AuthorAgeFilesLines
* Merge all deleteBranch as one function and also fix bug when delete branch ↵Lunny Xiao2021-06-073-146/+39
| | | | | | | | | | | | | don't close related PRs (#16067) * Fix bug when delete branch don't close related PRs * Merge all deletebranch as one method * Add missed branch.go * fix comment Co-authored-by: Lauris BH <lauris@nix.lv>
* Fixed assert statements. (#16089)KN4CK3R2021-06-072-3/+3
|
* Make commit info cancelable (#16032)zeripath2021-06-062-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Make modules/context.Context a context.Context Signed-off-by: Andrew Thornton <art27@cantab.net> * Simplify context calls Signed-off-by: Andrew Thornton <art27@cantab.net> * Set the base context for requests to the HammerContext Signed-off-by: Andrew Thornton <art27@cantab.net> * pass context into get-last-commit Signed-off-by: Andrew Thornton <art27@cantab.net> * Make commit_info cancellable Signed-off-by: Andrew Thornton <art27@cantab.net> * use context as context Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Rewrite of the LFS server (#15523)KN4CK3R2021-06-061-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Restructured code. Moved static checks out of loop. * Restructured batch api. Add support for individual errors. * Let router decide if LFS is enabled. * Renamed methods. * Return correct status from verify handler. * Unified media type check in router. * Changed error code according to spec. * Moved checks into router. * Removed invalid v1 api methods. * Unified methods. * Display better error messages. * Added size parameter. Create meta object on upload. * Use object error on invalid size. * Skip upload if object exists. * Moved methods. * Suppress fields in response. * Changed error on accept. * Added tests. * Use ErrorResponse object. * Test against message property. * Add support for the old invalid lfs client. * Fixed the check because MinIO wraps the error. * Use individual repositories. Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
* Add Image Diff for SVG files (#14867)KN4CK3R2021-06-057-57/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added type sniffer. * Switched content detection from base to typesniffer. * Added GuessContentType to Blob. * Moved image info logic to client. Added support for SVG images in diff. * Restore old blocked svg behaviour. * Added missing image formats. * Execute image diff only when container is visible. * add margin to spinner * improve BIN tag on image diffs * Default to render view. * Show image diff on incomplete diff. Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
* Fix case change in ownernames (#16045)zeripath2021-06-022-1/+16
| | | | | | | If you change the case of a username the change needs to be propagated to their repositories. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix language switch for install page (#16043)a10121127962021-06-012-1/+10
| | | Signed-off-by: a1012112796 <1012112796@qq.com>
* Add missing SameSite settings for the i_like_gitea cookie (#16037)zeripath2021-05-313-0/+3
| | | | | | | | | | The i_like_gitea cookie appears to be missing the SameSite settings. I think they were present at some point but may have been removed in a merge. This PR ensures that they are set. Fix #15972 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Hide mirror passwords on repo settings page (#16022)zeripath2021-05-311-0/+6
| | | | | | | This PR simply hides mirror passwords from being displayed on the repo settings page. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Make modules/context.Context a context.Context (#16031)zeripath2021-05-3111-20/+20
| | | | | | | | | | | | | | | * Make modules/context.Context a context.Context Signed-off-by: Andrew Thornton <art27@cantab.net> * Simplify context calls Signed-off-by: Andrew Thornton <art27@cantab.net> * Set the base context for requests to the HammerContext Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Close the dataRC reader sooner (#16023)zeripath2021-05-301-0/+5
| | | | | Fix #15932 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Improve assets handler middleware (#15961)Lunny Xiao2021-05-302-42/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use route to serve assets but not middleware * Fix build error with bindata tag * convert path to absolute * fix build * reduce function stack * Add tests for assets * Remove test for assets because they are not generated * Use a http function to serve assets * Still use middleware to serve assets then less middleware stack for assets * Move serveContent to original position * remove unnecessary blank line change * Fix bug for /assets* requests * clean code Co-authored-by: zeripath <art27@cantab.net>
* Add links to toggle WIP status (#14677)Jimmy Praet2021-05-271-0/+2
| | | | | | | | | | * Add links to toggle PR WIP status * Allow PR author to toggle WIP status * refactors and restyling, remove links from translations Co-authored-by: Norwin <noerw@users.noreply.github.com> Co-authored-by: silverwind <me@silverwind.io>
* add a new internal hook to save ssh log (#15787)a10121127962021-05-212-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | * add a new internal hook to save ssh log as title, when a ssh error ocure like #15785. only when switch ``RUN_MODE`` to dev can we found which error is ocure. But this way is not a good idea for production envirment. this changes try save ssh error mesage to the log file like other log by a new internal hook. I think it's usefull for find error message in production envirment. Thanks. Signed-off-by: a1012112796 <1012112796@qq.com> * rename and fix nit * Update modules/private/hook.go Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* api: fix overly strict edit pr permissions (#15900)Norwin2021-05-191-1/+1
| | | | Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
* Restore token authentication for git http when 2FA active (#15915)zeripath2021-05-181-1/+1
| | | | | | | | | | There was a small regression in #15303 whereby token auth with 2FA active would be disallowed. This PR fixes this. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Prevent double-login for Git HTTP and LFS and simplify login (#15303)zeripath2021-05-153-107/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Prevent double-login for Git HTTP and LFS and simplify login There are a number of inconsistencies with our current methods for logging in for git and lfs. The first is that there is a double login process. This is particularly evident in 1.13 where there are no less than 4 hash checks for basic authentication due to the previous IsPasswordSet behaviour. This duplicated code had individual inconsistencies that were not helpful and caused confusion. This PR does the following: * Remove the specific login code from the git and lfs handlers except for the lfs special bearer token * Simplify the meaning of DisableBasicAuthentication to allow Token and Oauth2 sign-in. * The removal of the specific code from git and lfs means that these both now have the same login semantics and can - if not DisableBasicAuthentication - login from external services. Further it allows Oauth2 token authentication as per our standard mechanisms. * The change in the recovery handler prevents the service from re-attempting to login - primarily because this could easily cause a further panic and it is wasteful. * add test Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net>
* Close the gitrepo when deleting the repository (#15876)zeripath2021-05-143-0/+13
| | | | Signed-off-by: Andrew Thornton <art27@cantab.net>
* Restore PAM user autocreation functionality (#15825)zeripath2021-05-131-0/+2
| | | | | | | | | | | | | | | | | * Restore PAM user autocreation functionality PAM autoregistration of users currently fails due to email invalidity. This PR adds a new setting to PAM to allow an email domain to be set or just sets the email to the noreply address and if that fails falls back to uuid@localhost Fix #15702 Signed-off-by: Andrew Thornton <art27@cantab.net> * As per KN4CKER Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add mimetype mapping settings (#15133)Adam Szatyin2021-05-101-0/+8
| | | | | | | | | | | | | * Fix APK's Content-Type header * Fix case sensitive comparison * Add custom mime type mapping for downloadable files * Add documentation for MIME type mapping * Rename download.mimetype.mapping configuration to repository.mimetype_mapping Co-authored-by: zeripath <art27@cantab.net>
* don't record error when request a non-exist user (#15819)Lunny Xiao2021-05-101-1/+1
| | | | | | | | | | * don't record error when request a non-exist user * Update routers/repo/http.go Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix goth user infer bug (#15821)Lunny Xiao2021-05-101-5/+10
|
* Move restore repo to internal router and invoke from command to avoid open ↵Lunny Xiao2021-05-102-0/+52
| | | | | | | | | | | the same db file or queues files (#15790) * Move restore repo to internal router and invoke from command to avoid open the same db file or queues files * Follow @zeripath's review * set no timeout for resotre repo private request * make restore repo cancelable
* Use single shared random string generation function (#15741)silverwind2021-05-101-2/+2
| | | | | | | | | | | | | | | | | | * Use single shared random string generation function - Replace 3 functions that do the same with 1 shared one - Use crypto/rand over math/rand for a stronger RNG - Output only alphanumerical for URL compatibilty Fixes: #15536 * use const string method * Update modules/avatar/avatar.go Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: a1012112796 <1012112796@qq.com>
* On open repository open common cat file batch and batch-check (#15667)zeripath2021-05-101-0/+12
| | | | | | | Use common git cat-file --batch and git cat-file --batch-check to significantly reduce calls to git. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Return go-get info on subdirs (#15642)zeripath2021-05-092-65/+88
| | | | | | | | | | This PR is an alternative to #15628 and makes the go get handler a handler. Fix #15625 Close #15628 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix incorrect asset URL (#15805)silverwind2021-05-091-1/+1
| | | | Fixes another regression from https://github.com/go-gitea/gitea/pull/15219.
* Allow only internal registration (#15795)65432021-05-092-3/+11
| | | | | * Add ALLOW_ONLY_INTERNAL_REGISTRATION into settings * OpenID respect setting too
* Ensure that ctx.Written is checked after issues(...) calls (#15797)zeripath2021-05-091-0/+3
| | | | | Fix issue noted in #15783 Signed-off-by: Andrew Thornton <art27@cantab.net>
* [API] make change repo settings work on empty repos (#15778)65432021-05-082-9/+9
| | | | | * API: Fix #15602 * Add TEST
* Add selecting tags on the compare page (#15723)Jonathan Tran2021-05-071-16/+37
| | | | | | | | | | | * Add selecting tags on the compare page * Remove unused condition and change indentation * Fix tag tab in dropdown to be black * Add compare tag integration test Co-authored-by: Jonathan Tran <jon@allspice.io>
* Feature/oauth userinfo (#15721)N. L. H2021-05-062-0/+74
| | | | | | | | | | | | | | | | | | | | | | * Implemented userinfo #8534 * Make lint happy * Add userinfo endpoint to openid-configuration * Give an error when uid equals 0 * Implemented BearerTokenErrorCode handling * instead of ctx.error use ctx.json so that clients parse error and error_description correctly * Removed unneeded if statement * Use switch instead of subsequent if statements Have a default for unknown errorcodes. Co-authored-by: Nils Hillmann <hillmann@nlh-software.de> Co-authored-by: nlhsoftware <nlhsoftware@noreply.localhost>
* fix some ui bug about draft release (#15137)a10121127962021-05-062-10/+18
| | | | | | | | | | | | | | | | | | | * fix some ui bug about draft release - should not show draft release in tag list because it will't create real tag - still show draft release without tag and commit message for draft release instead of 404 error - remove tag load for attachement links because it's useless Signed-off-by: a1012112796 <1012112796@qq.com> * add test code * fix test That's because has added a new release in relaese test database. * fix dropdown link for draft release
* Fix broken avatars since #15301 (#15731)zeripath2021-05-051-2/+2
| | | | | | | There was a missing * from the avatars routes in #15301. Fix #15727 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Use route rather than use thus reducing the number of stack frames (#15301)zeripath2021-05-042-46/+51
| | | | | | | | | | | | Since the move to Chi the number of stack frames has proliferated somewhat catastrophically and we're up to 96 frames with multiple tests of the url outside of a trie which is inefficient. This PR reduces the number of stack frames by 6 through careful use of Route, moves Captcha into its own router so that it only fires on Captcha routes, similarly for avatars and repo-avatars. The robots.txt, / and apple-touch-icon.png are moved out of requiring Contexter. It moves access logger higher in the stack frame because there is no reason why it can't be higher. Extract from #15186 Contains #15292
* Add compare tag dropdown to releases page (#15695)Jonathan Tran2021-05-031-0/+12
| | | | | | | | | | * Add compare tag dropdown to releases page * Change defaults to be more intuitive and remove unneeded option * Fix to select branch on releases page Co-authored-by: Jonathan Tran <jon@allspice.io> Co-authored-by: Kyle D <kdumontnu@gmail.com>
* Addition to (Add Location, Website and Description to API #15675) (#15690)KN4CK3R2021-05-021-0/+3
| | | | | | | | | * Use same name as other structs. * Sync with normal forms. * Edit description with API. * Workaround for nil value.
* Fixed several activation bugs (#15473)KN4CK3R2021-04-302-6/+38
| | | | | | | | | | | * Removed unneeded form tag. * Fixed typo. * Fixed NPE. * Use better error page. * Splitted GET and POST.
* Unified link creation. (#15619)KN4CK3R2021-04-306-11/+10
|
* Added missing prefix on install route. (#15677)KN4CK3R2021-04-301-0/+1
| | | Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix readme render bug (#15649)Lunny Xiao2021-04-281-0/+1
|
* add `/assets` as root dir of public files (#15219)a10121127962021-04-282-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | * add `/assets` as root dir of public files Signed-off-by: a1012112796 <1012112796@qq.com> * move serviceworker.js * make fmt * fix some link * fix test * Apply suggestions from code review Co-authored-by: silverwind <me@silverwind.io> * Apply suggestions from code review Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* Attachment support repository route (#15580)Lunny Xiao2021-04-231-0/+1
|
* Refactor renders (#15175)Lunny Xiao2021-04-1913-76/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor renders * Some performance optimization * Fix comment * Transform reader * Fix csv test * Fix test * Fix tests * Improve optimaziation * Fix test * Fix test * Detect file encoding with reader * Improve optimaziation * reduce memory usage * improve code * fix build * Fix test * Fix for go1.15 * Fix render * Fix comment * Fix lint * Fix test * Don't use NormalEOF when unnecessary * revert change on util.go * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * rename function * Take NormalEOF back Co-authored-by: zeripath <art27@cantab.net>
* add well-known config for OIDC (#15355)techknowlogick2021-04-152-0/+11
| | | | | | | | | | | | | | * add well-known config for OIDC * spacing per feedback * Update oidc_wellknown.tmpl * add id_token * Update oidc_wellknown.tmpl Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix bug clone wiki (#15499)Lunny Xiao2021-04-151-0/+10
| | | | | | | Fix #15494 Co-authored-by: Lauris BH <lauris@nix.lv>
* Performance improvement for list pull requests (#15447)Lunny Xiao2021-04-152-17/+12
|
* Disable Stars config option (#14653)Kyle D2021-04-152-0/+22
| | | | | | | * Add config option to disable stars * Replace "stars" with watched in user profile * Add documentation
* fix wrong file link in code search page (#15466)a10121127962021-04-141-2/+1
| | | | | | | | | | | | | | | | | | in previous the grenrated link is ``testg/testrepo/src/commit/....`` which is not right. the right version is ``/testg/testrepo/.......`` (start wiht ``/``) or ``http://127.0.0.1:3000/xxxxx`` (full link) to make it hase same result with explore page I choose the secound style. fix #15438 Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: 6543 <6543@obermui.de>
* OAuth2 auto-register (#5123)Martin Michaelis2021-04-142-132/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactored handleOAuth2SignIn in routers/user/auth.go The function handleOAuth2SignIn was called twice but some code path could only be reached by one of the invocations. Moved the unnecessary code path out of handleOAuth2SignIn. * Refactored user creation There was common code to create a user and display the correct error message. And after the creation the only user should be an admin and if enabled a confirmation email should be sent. This common code is now abstracted into two functions and a helper function to call both. * Added auto-register for OAuth2 users If enabled new OAuth2 users will be registered with their OAuth2 details. The UserID, Name and Email fields from the gothUser are used. Therefore the OpenID Connect provider needs additional scopes to return the coresponding claims. * Added error for missing fields in OAuth2 response * Linking and auto linking on oauth2 registration * Set default username source to nickname * Add automatic oauth2 scopes for github and google * Add hint to change the openid connect scopes if fields are missing * Extend info about auto linking security risk Co-authored-by: Viktor Kuzmin <kvaster@gmail.com> Signed-off-by: Martin Michaelis <code@mgjm.de>