1
0
mirror of https://git.cloudron.io/cloudron/gitea-app synced 2025-09-25 22:47:24 +00:00

Compare commits

..

52 Commits

Author SHA1 Message Date
Girish Ramakrishnan
4301fd5117 Version 1.13.4 2019-09-08 11:04:31 -07:00
Girish Ramakrishnan
7aebe88c3e Update gitea to 1.9.3 2019-09-08 10:51:41 -07:00
Girish Ramakrishnan
91cc96705e Version 1.13.3 2019-08-22 18:07:30 -07:00
Girish Ramakrishnan
6fe012f901 Update gitea to 1.9.2 2019-08-22 18:01:55 -07:00
Girish Ramakrishnan
29197622fc Remove session config now that migration is done 2019-08-19 20:11:47 -07:00
Girish Ramakrishnan
3adbf0b442 Version 1.13.2 2019-08-19 17:29:50 -07:00
Girish Ramakrishnan
6c0a2ab20b no need to relogin since session persists 2019-08-19 17:29:26 -07:00
Girish Ramakrishnan
1943723dd3 Use file based sessions
Fixes #5
2019-08-19 17:10:23 -07:00
Johannes Zellner
2d15227f2e Update chromedriver 2019-08-15 14:02:50 +02:00
Johannes Zellner
cbc0bfb222 Bump version for 1.9.1 2019-08-15 13:37:27 +02:00
Johannes Zellner
10df3c6ba9 Bump version for Gitea 1.9.0 2019-07-31 18:16:42 +02:00
Johannes Zellner
047ec295bc Remove unused test requires 2019-07-31 18:16:28 +02:00
Johannes Zellner
31b8a17230 Ensure we never test with the default port 2019-07-31 18:15:17 +02:00
Girish Ramakrishnan
ebb46bb7ac Version 1.12.0 2019-06-17 14:40:15 -07:00
Girish Ramakrishnan
53f180ef95 Update manifest to v2 2019-06-17 14:30:49 -07:00
Girish Ramakrishnan
d89fc6a0ec Update Gitea to 1.8.3 2019-06-17 14:29:03 -07:00
Girish Ramakrishnan
1039d32995 Version 1.11.0 2019-06-04 19:27:00 -07:00
Girish Ramakrishnan
6b25bb66c7 Fix up tests 2019-06-04 19:26:26 -07:00
Girish Ramakrishnan
e566c94b43 Bring in various gogs features
better custom app.ini
optional sso support
always create root user
2019-06-04 17:15:20 -07:00
Girish Ramakrishnan
0d2e1cfff0 Remove admin propagation 2019-06-04 17:07:59 -07:00
Girish Ramakrishnan
f830faac79 Add lock file 2019-05-30 09:56:01 -07:00
Girish Ramakrishnan
319e6d275c Version 1.10.2 2019-05-30 09:55:07 -07:00
Girish Ramakrishnan
9128339000 Update modules 2019-05-30 09:50:05 -07:00
Girish Ramakrishnan
f7ca27425a Update Gitea to 1.8.2 2019-05-30 09:36:33 -07:00
Johannes Zellner
9907d1c9cd Bump version for 1.8.1 2019-05-09 11:30:29 +02:00
Girish Ramakrishnan
8d16e4d734 Version 1.10.0 2019-04-22 11:51:14 -07:00
Girish Ramakrishnan
150d490801 Update Gitea to 1.8.0 2019-04-22 11:44:21 -07:00
Johannes Zellner
4a4e4ff4f1 Bump version for 1.7.6 2019-04-15 12:52:36 +02:00
Girish Ramakrishnan
24e9499d9c Version 1.9.5 2019-03-28 05:55:37 -07:00
Girish Ramakrishnan
8c66d9ed76 Update gitea to 1.7.5 2019-03-28 05:41:23 -07:00
Girish Ramakrishnan
60d06af70d Version 1.9.4 2019-03-13 12:57:47 -07:00
Girish Ramakrishnan
15c28c940d Update gitea to 1.7.4 2019-03-13 11:58:10 -07:00
Johannes Zellner
5f5d3a7b53 Bump version for 1.7.3 2019-02-28 15:17:15 +01:00
Johannes Zellner
0902b92a7d Bump version for 1.7.2 2019-02-18 14:23:23 +01:00
Girish Ramakrishnan
d675d60e1d Version 1.9.1 2019-01-31 09:37:08 -08:00
Girish Ramakrishnan
07d3c6bfcf Update Gitea to 1.7.1 2019-01-31 09:29:33 -08:00
Girish Ramakrishnan
60f9045cbb Version 1.9.0 2019-01-22 12:59:18 -08:00
Girish Ramakrishnan
a633dcab9a Update Gitea to 1.7.0 2019-01-22 12:45:47 -08:00
Girish Ramakrishnan
435f30cf8c Version 1.8.4 2019-01-16 10:47:09 -08:00
Girish Ramakrishnan
157f500660 Update Gitea to 1.6.4 2019-01-16 10:40:53 -08:00
Girish Ramakrishnan
2eae86ee53 Version 1.8.3 2019-01-10 09:38:37 -08:00
Girish Ramakrishnan
3993229ac3 Update Gitea to 1.6.3 2019-01-10 09:29:23 -08:00
Girish Ramakrishnan
9793215e7c Version 1.8.2 2018-12-26 11:47:58 -08:00
Girish Ramakrishnan
6e04300610 Update gitea to 1.6.2 2018-12-26 09:54:13 -08:00
Girish Ramakrishnan
587235be2b Version 1.8.1 2018-12-10 12:02:41 -08:00
Girish Ramakrishnan
de3369808e Update gitea to 1.6.1 2018-12-10 11:53:26 -08:00
Johannes Zellner
5e99be936a Bump version for 1.6.0 2018-11-23 12:13:37 +01:00
Johannes Zellner
12f58af585 Bump version 2018-11-02 08:55:25 +01:00
Johannes Zellner
9971919cf9 Make tests use a different port to avoid conflicts 2018-11-02 08:53:38 +01:00
Johannes Zellner
65bc13c2b7 Update to 1.5.3 2018-11-02 08:19:31 +01:00
Girish Ramakrishnan
c231b12f2d Version 1.7.1 2018-10-11 08:09:22 -07:00
Girish Ramakrishnan
1265366151 Update Gitea to 1.5.2 2018-10-11 08:03:58 -07:00
10 changed files with 2266 additions and 82 deletions

170
CHANGELOG
View File

@@ -190,3 +190,173 @@
[1.7.0] [1.7.0]
* Update base image * Update base image
[1.7.1]
* Update Gitea to 1.5.2
[1.7.2]
* Update Gitea to 1.5.3
* Security
* Fix remote command execution vulnerability in upstream library (#5177) (#5196)
[1.8.0]
* Update Gitea to 1.6.0
[1.8.1]
* Update Gitea to 1.6.1
[1.8.2]
* Update Gitea to 1.6.2
* SECURITY
* Sanitize uploaded file names (#5571) (#5573)
* HTMLEncode user added text (#5570) (#5575)
* BUGFIXES
* Fix indexer reindex bug when gitea restart (#5563) (#5564)
* Fix bug when a read perm user to edit his issue (#5516) (#5534)
* Detect force push failure on deletion of protected branches (#5522) (#5531)
* Fix forgot deletion of notification when delete repository (#5506) (#5514)
* Fix undeleted content when deleting user (#5429) (#5509)
* Fix empty wiki (#5504) (#5508)
[1.8.3]
* Update Gitea to 1.6.3
* SECURITY: Prevent DeleteFilePost doing arbitrary deletion (#5631)
* BUGFIX: Fix wrong text getting saved on editing second comment on an issue (#5608)
[1.8.4]
* Update Gitea to 1.6.4
* Fix SSH key now can be reused as public key after deleting as deploy key (#5671) (#5685)
* When redirecting clean the path to avoid redirecting to external site (#5669) (#5703)
* Fix to use correct value for "MSpan Structures Obtained" (#5706) (#5715)
[1.9.0]
* Update Gitea to 1.7.0
[1.9.1]
* Update Gitea to 1.7.1
* [Changelog](https://github.com/go-gitea/gitea/releases/tag/v1.7.1)
* Disable redirect for i18n (#5910) (#5916)
* Only allow local login if password is non-empty (#5906) (#5908)
* Fix go-get URL generation (#5905) (#5907)
* Fix TLS errors when using acme/autocert for local connections (#5820) (#5826)
* Request for public keys only if LDAP attribute is set (#5816) (#5819)
* Fix delete correct temp directory (#5840) (#5839)
* Fix an error while adding a dependency via UI (#5862) (#5876)
* Fix null pointer in attempt to Sudo if not logged in (#5872) (#5884)
* When creating new repository fsck option should be enabled (#5817) (#5885)
* Prevent nil dereference in mailIssueCommentToParticipants (#5891) (#5895) (#5894)
* Fix bug when read public repo lfs file (#5913) (#5912)
* Respect value of REQUIRE_SIGNIN_VIEW (#5901) (#5915)
* Fix compare button on upstream repo leading to 404 (#5877) (#5914)
[1.9.2]
* Update Gitea to 1.7.2
* Remove all CommitStatus when a repo is deleted (#5940) (#5941)
* Fix notifications on pushing with deploy keys by setting hook environment variables (#5935) (#5944)
* Silence console logger in gitea serv (#5887) (#5943)
* Handle milestone webhook events for issues and PR (#5947) (#5955)
* Show user who created the repository instead of the organization in action feed (#5948) (#5956)
* Fix ssh deploy and user key constraints (#1357) (#5939) (#5966)
* Fix bug when deleting a linked account will removed all (#5989) (#5990)
* Fix empty ssh key importing in ldap (#5984) (#6009)
* Fix metrics auth token detection (#6006) (#6017)
* Create repository on organisation by default on its dashboard (#6026) (#6048)
* Make sure labels are actually returned in API (#6053) (#6059)
* Switch to more recent build of xgo (#6070) (#6072)
* In basic auth check for tokens before call UserSignIn (#5725) (#6083)
[1.9.3]
* Update Gitea to 1.7.3
* Fix server 500 when trying to migrate to an already existing repository (#6188) (#6197)
* Load Issue attributes for API /repos/{owner}/{repo}/issues/{index} (#6122) (#6185)
* Fix bug whereby user could change private repository to public when force private enabled. (#6156) (#6165)
* Fix bug when update owner team then visit team's repo return 404 (#6119) (#6166)
* Fix heatmap and repository menu display in Internet Explorer 9+ (#6117) (#6137)
* Fix prohibit login check on authorization (#6106) (#6115)
* Fix LDAP protocol error regression by moving to ldap.v3 (#6105) (#6107)
* Fix deadlock in webhook PullRequest (#6102) (#6104)
* Fix redirect loop when password change is required and Gitea is installed as a suburl (#5965) (#6101)
* Fix compare button regression (#5929) (#6098)
* Recover panic in orgmode.Render if bad orgfile (#4982) (#5903) (#6097)
[1.9.4]
* Update Gitea to 1.7.4
* Fix potential XSS vulnerability in repository description. (#6306) (#6308)
* Fix wrong release commit id (#6224) (#6300)
* Fix panic on empty signed commits (#6292) (#6300)
* Fix organization dropdown not being scrollable when using mouse wheel (#5988) (#6246)
* Fix displaying dashboard even if required to change password (#6214) (#6215)
[1.9.5]
* Update Gitea to 1.7.5
* unitTypeCode not being used in accessLevelUnit (#6419) (#6423)
* ParsePatch function to work with quoted diff --git strings (#6323) (#6332)
[1.9.6]
* Update Gitea to 1.7.6
* Prevent remote code execution vulnerability with mirror repo URL settings (#6593) (#6595)
* Allow resend of confirmation email when logged in (#6482) (#6487)
[1.10.0]
* Update Gitea to 1.8.0
* [Full changelog](https://github.com/go-gitea/gitea/releases/tag/v1.8.0)
* Prevent remote code execution vulnerability with mirror repo URL settings (#6593) (#6594)
* Resolve 2FA bypass on API (#6676) (#6674)
* Prevent the creation of empty sessions for non-logged in users (#6690) (#6677)
* Expose issue stopwatch toggling via API (#5970)
* Pull request conflict files detection (#5951)
* Implement "conversation lock" for issue comments (#5073)
* Feature: Archive repos (#5009)
* Allow to set organization visibility (public, internal, private) (#1763)
* Added URL mapping for Release attachments like on github.com (#1707)
[1.10.1]
* Update Gitea to 1.8.1
[1.10.2]
* Update Gitea to 1.8.2
[1.11.0]
* better custom app.ini integration
* optional sso support
[1.12.0]
* Update Gitea to 1.8.3
* Update manifest to v2
[1.13.0]
* Update Gitea to 1.9.0
[1.13.1]
* Update Gitea to 1.9.1
[1.13.2]
* Make sessions persist restarts
[1.13.3]
* Update Gitea to 1.9.2
* Fix wrong sender when send slack webhook (#7918) (#7924)
* Upload support text/plain; charset=utf8 (#7899)
* Lfs/lock: round locked_at timestamp to second (#7872) (#7875)
* Fix non existent milestone with 500 error (#7867) (#7873)
* SECURITY
* Fix No PGP signature on 1.9.1 tag (#7874)
* Release built with go 1.12.9 to fix security fixes in golang std lib, ref: https://groups.google.com/forum/#!msg/golang-announce/oeMaeUnkvVE/a49yvTLqAAAJ
* ENHANCEMENT
* Fix pull creation with empty changes (#7920) (#7926)
* BUILD
* Drone/docker: prepare multi-arch release + provide arm64 image (#7571) (#7884)
[1.13.4]
* Update Gitea to 1.9.3
* Fix go get from a private repository with Go 1.13 (#8100)
* Strict name matching for Repository.GetTagID() (#8082)
* Avoid ambiguity of branch/directory names for the git-diff-tree command (#8070)
* Add change title notification for issues (#8064)
* Run CORS handler first for /api routes (#7967) (#8053)
* Evaluate emojis in commit messages in list view (#8044)
* Fix failed to synchronize tags to releases for repository (#7990) (#7994)
* Fix adding default Telegram webhook (#7972) (#7992)
* Abort synchronization from LDAP source if there is some error (#7965)
* Fix deformed emoji in commit message (#8071)
* Keep blame view buttons sequence consistent with normal view when viewing a file (#8007) (#8009)

View File

@@ -4,7 +4,7 @@
"author": "Gitea developers", "author": "Gitea developers",
"description": "file://DESCRIPTION.md", "description": "file://DESCRIPTION.md",
"tagline": "A painless self-hosted Git Service", "tagline": "A painless self-hosted Git Service",
"version": "1.7.0", "version": "1.13.4",
"healthCheckPath": "/healthcheck", "healthCheckPath": "/healthcheck",
"httpPort": 3000, "httpPort": 3000,
"addons": { "addons": {
@@ -20,10 +20,11 @@
"defaultValue": 29418 "defaultValue": 29418
} }
}, },
"manifestVersion": 1, "manifestVersion": 2,
"website": "https://gitea.io", "website": "https://gitea.io",
"contactEmail": "apps@cloudron.io", "contactEmail": "apps@cloudron.io",
"icon": "file://logo.png", "icon": "file://logo.png",
"optionalSso": true,
"mediaLinks": [ "mediaLinks": [
"https://s3.amazonaws.com/cloudron-app-screenshots/io.gitea.cloudronapp/f89a2ab8d49094c80589f69a2d60bef63b2dbb62/1.png", "https://s3.amazonaws.com/cloudron-app-screenshots/io.gitea.cloudronapp/f89a2ab8d49094c80589f69a2d60bef63b2dbb62/1.png",
"https://s3.amazonaws.com/cloudron-app-screenshots/io.gitea.cloudronapp/f89a2ab8d49094c80589f69a2d60bef63b2dbb62/2.png", "https://s3.amazonaws.com/cloudron-app-screenshots/io.gitea.cloudronapp/f89a2ab8d49094c80589f69a2d60bef63b2dbb62/2.png",
@@ -34,6 +35,6 @@
"tags": [ "version control", "git", "code hosting", "development" ], "tags": [ "version control", "git", "code hosting", "development" ],
"changelog": "file://CHANGELOG", "changelog": "file://CHANGELOG",
"postInstallMessage": "file://POSTINSTALL.md", "postInstallMessage": "file://POSTINSTALL.md",
"minBoxVersion": "1.10.0", "minBoxVersion": "4.1.4",
"documentationUrl": "https://cloudron.io/documentation/apps/gitea/" "documentationUrl": "https://cloudron.io/documentation/apps/gitea/"
} }

View File

@@ -1,4 +1,4 @@
This app packages Gitea <upstream>1.5.1</upstream> This app packages Gitea <upstream>1.9.3</upstream>
Gitea is a painless self-hosted Git service. It is similar to GitHub, Bitbucket or Gitlab. Gitea is a painless self-hosted Git service. It is similar to GitHub, Bitbucket or Gitlab.

View File

@@ -1,5 +1,7 @@
FROM cloudron/base:1.0.0@sha256:147a648a068a2e746644746bbfb42eb7a50d682437cead3c67c933c546357617 FROM cloudron/base:1.0.0@sha256:147a648a068a2e746644746bbfb42eb7a50d682437cead3c67c933c546357617
ARG VERSION=1.9.3
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y openssh-server git && \ apt-get install -y openssh-server git && \
rm -rf /etc/ssh_host_* && \ rm -rf /etc/ssh_host_* && \
@@ -13,8 +15,8 @@ RUN adduser --disabled-login --gecos 'Gitea' git
RUN passwd -d git RUN passwd -d git
RUN mkdir -p /home/git/gitea RUN mkdir -p /home/git/gitea
## TODO: use redis as well WORKDIR /home/git
RUN curl -L https://dl.gitea.io/gitea/1.5.1/gitea-1.5.1-linux-amd64 -o /home/git/gitea/gitea \ RUN curl -L https://dl.gitea.io/gitea/${VERSION}/gitea-${VERSION}-linux-amd64 -o /home/git/gitea/gitea \
&& chmod +x /home/git/gitea/gitea && chmod +x /home/git/gitea/gitea
# setup config paths # setup config paths

View File

@@ -1,12 +1,14 @@
This app integrates with the Cloudron SSO. Admins on Cloudron automatically A default admin user has been setup with the following credentials (use the `Local` authentication source when logging in):
become admins on Gitea.
If you want to disable Cloudron SSO, do the following: ```
username: root
password: changeme
```
* Admin Panel -> Authentication -> 'cloudron' -> Uncheck 'This authentication is activated' **Note:** Please change the password and email immediately after installation.
* Admin Panel -> Users -> Change Authentication Source to 'Local' and also give a password
You can edit `/app/data/app.ini` and add any custom configuration. See the <sso>
[configuration cheat sheet](https://docs.gitea.io/en-us/config-cheat-sheet) This app integrates with the Cloudron SSO. Cloudron users can login and use Gitea
for more information. using the `Cloudron` authentication source.
</sso>

View File

@@ -95,3 +95,11 @@ PATH =
[indexer] [indexer]
; this setting is protected and can't be modified ; this setting is protected and can't be modified
ISSUE_INDEXER_PATH = /app/data/appdata/indexers/issues.bleve ISSUE_INDEXER_PATH = /app/data/appdata/indexers/issues.bleve
[session]
PROVIDER = file
PROVIDER_CONFIG = /run/gitea/sessions
COOKIE_SECURE = true
COOKIE_NAME = cloudron_gitea
GC_INTERVAL_TIME = 2592000

View File

@@ -2,32 +2,61 @@
set -eu -o pipefail set -eu -o pipefail
mkdir -p /run/gitea/tmp/uploads /run/sshd mkdir -p /run/gitea/tmp/uploads /run/sshd /run/gitea/sessions
setup_ldap_source() { setup_ldap_source() {
set -eu set -eu
# Wait for gitea to finish db setup, before we insert ldap source in db # Get the existing LDAP source status. This allows the user to disable LDAP
while ! curl --fail http://localhost:3000/healthcheck; do # Note that this method is deprecated since this app now supports optionalSso
echo "Waiting for gitea to come up" ldap_status=$(mysql -u"${CLOUDRON_MYSQL_USERNAME}" -p"${CLOUDRON_MYSQL_PASSWORD}" -h mysql --database="${CLOUDRON_MYSQL_DATABASE}" -N -B -e "select is_actived from login_source WHERE name='cloudron';")
sleep 1 [[ -z "${ldap_status}" ]] && ldap_status="1"
done
now=$(date +%s) now=$(date +%s)
# Get the existing LDAP source status. This allows the user to disable LDAP if mysql -u"${CLOUDRON_MYSQL_USERNAME}" -p"${CLOUDRON_MYSQL_PASSWORD}" -h mysql --database="${CLOUDRON_MYSQL_DATABASE}" \
ldap_status=$(mysql -u"${MYSQL_USERNAME}" -p"${MYSQL_PASSWORD}" -h mysql --database="${MYSQL_DATABASE}" -N -B -e "select is_actived from login_source WHERE name='cloudron';") -e "REPLACE INTO login_source (id, type, name, is_actived, cfg, created_unix, updated_unix) VALUES (1,2,'cloudron',${ldap_status},'{\"Name\":\"cloudron\",\"Host\":\"${CLOUDRON_LDAP_SERVER}\",\"Port\":${CLOUDRON_LDAP_PORT},\"UseSSL\":false,\"SkipVerify\":true,\"BindDN\":\"${CLOUDRON_LDAP_BIND_DN}\",\"BindPassword\":\"${CLOUDRON_LDAP_BIND_PASSWORD}\",\"UserBase\":\"${CLOUDRON_LDAP_USERS_BASE_DN}\",\"AttributeUsername\":\"username\",\"AttributeName\":\"displayname\",\"AttributeSurname\":\"\",\"AttributeMail\":\"mail\",\"Filter\":\"(\\\\u007C(mail=%[1]s)(username=%[1]s))\"}','${now}','${now}');"; then
[[ -z "${ldap_status}" ]] && ldap_status="1" echo "==> LDAP Authentication was setup with activation status ${ldap_status}"
if mysql -u"${MYSQL_USERNAME}" -p"${MYSQL_PASSWORD}" -h mysql --database="${MYSQL_DATABASE}" \
-e "REPLACE INTO login_source (id, type, name, is_actived, cfg, created_unix, updated_unix) VALUES (1,2,'cloudron',${ldap_status},'{\"Name\":\"cloudron\",\"Host\":\"${LDAP_SERVER}\",\"Port\":${LDAP_PORT},\"UseSSL\":false,\"SkipVerify\":true,\"BindDN\":\"${LDAP_BIND_DN}\",\"BindPassword\":\"${LDAP_BIND_PASSWORD}\",\"UserBase\":\"${LDAP_USERS_BASE_DN}\",\"AttributeUsername\":\"username\",\"AttributeName\":\"displayname\",\"AttributeSurname\":\"\",\"AttributeMail\":\"mail\",\"Filter\":\"(\\\\u007C(mail=%[1]s)(username=%[1]s))\",\"AdminFilter\":\"(memberof=cn=admins,${LDAP_GROUPS_BASE_DN})\"}','${now}','${now}');"; then
echo "LDAP Authentication was setup with status ${ldap_status}"
else else
echo "Failed to setup LDAP authentication" echo "==> Failed to setup LDAP authentication"
exit 1 exit 1
fi fi
} }
setup_root_user() {
set -eu
if sudo -H -u git /home/git/gitea/gitea admin create-user --name root --password changeme --email test@cloudron.io --admin -c /run/gitea/app.ini; then
echo "==> root user added"
else
echo "==> Failed to add root user"
exit 1
fi
}
setup_auth() {
set -eu
# Wait for gitea to finish db setup, before we do any db operations
while ! curl --fail http://localhost:3000/healthcheck; do
echo "==> Waiting for gitea to come up"
sleep 1
done
echo "==> Gitea is up, setting up auth"
if [[ -n "${CLOUDRON_LDAP_SERVER:-}" ]]; then
setup_ldap_source
fi
user_count=$(mysql -u"${CLOUDRON_MYSQL_USERNAME}" -p"${CLOUDRON_MYSQL_PASSWORD}" -h mysql --database="${CLOUDRON_MYSQL_DATABASE}" -N -B -e "SELECT count(*) FROM user;")
# be careful, not to create root user for existing LDAP based installs
if [[ "${user_count}" == "0" ]]; then
echo "==> Setting up root user for first run"
setup_root_user
fi
}
# SSH_PORT can be unset to disable SSH # SSH_PORT can be unset to disable SSH
disable_ssh="false" disable_ssh="false"
if [[ -z "${SSH_PORT:-}" ]]; then if [[ -z "${SSH_PORT:-}" ]]; then
@@ -52,30 +81,26 @@ chmod 0644 /app/data/sshd/*.pub
sed -e "s/^Port .*/Port ${SSH_PORT}/" /etc/ssh/sshd_config > /run/gitea/sshd_config sed -e "s/^Port .*/Port ${SSH_PORT}/" /etc/ssh/sshd_config > /run/gitea/sshd_config
cp /home/git/app.ini.template "/run/gitea/app.ini" if [[ ! -f /app/data/app.ini ]]; then
echo -e "; Add customizations here - https://docs.gitea.io/en-us/config-cheat-sheet/" > /app/data/app.ini
# create default user config file echo "==> Generating new SECRET_KEY"
if ! [ -f /app/data/app.ini ]; then
cp /home/git/app.ini.template /app/data/app.ini
fi
if [ "$(crudini --get /app/data/app.ini security SECRET_KEY)" == "##SECRET_KEY" ]; then
echo "Generating new SECRET_KEY"
crudini --set "/app/data/app.ini" security SECRET_KEY $(pwgen -1 -s) crudini --set "/app/data/app.ini" security SECRET_KEY $(pwgen -1 -s)
fi fi
# merge user config file # merge user config file
cp /home/git/app.ini.template "/run/gitea/app.ini"
crudini --merge "/run/gitea/app.ini" < "/app/data/app.ini" crudini --merge "/run/gitea/app.ini" < "/app/data/app.ini"
# override important values # override important values
crudini --set "/run/gitea/app.ini" database DB_TYPE mysql crudini --set "/run/gitea/app.ini" database DB_TYPE mysql
crudini --set "/run/gitea/app.ini" database HOST "${MYSQL_HOST}:${MYSQL_PORT}" crudini --set "/run/gitea/app.ini" database HOST "${CLOUDRON_MYSQL_HOST}:${CLOUDRON_MYSQL_PORT}"
crudini --set "/run/gitea/app.ini" database NAME "${MYSQL_DATABASE}" crudini --set "/run/gitea/app.ini" database NAME "${CLOUDRON_MYSQL_DATABASE}"
crudini --set "/run/gitea/app.ini" database USER "${MYSQL_USERNAME}" crudini --set "/run/gitea/app.ini" database USER "${CLOUDRON_MYSQL_USERNAME}"
crudini --set "/run/gitea/app.ini" database PASSWD "${MYSQL_PASSWORD}" crudini --set "/run/gitea/app.ini" database PASSWD "${CLOUDRON_MYSQL_PASSWORD}"
crudini --set "/run/gitea/app.ini" database SSL_MODE "disable" crudini --set "/run/gitea/app.ini" database SSL_MODE "disable"
crudini --set "/run/gitea/app.ini" server PROTOCOL "http" crudini --set "/run/gitea/app.ini" server PROTOCOL "http"
crudini --set "/run/gitea/app.ini" server DOMAIN "${APP_DOMAIN}" crudini --set "/run/gitea/app.ini" server DOMAIN "${CLOUDRON_APP_DOMAIN}"
crudini --set "/run/gitea/app.ini" server ROOT_URL "https://%(DOMAIN)s/" crudini --set "/run/gitea/app.ini" server ROOT_URL "https://%(DOMAIN)s/"
crudini --set "/run/gitea/app.ini" server HTTP_ADDR "" crudini --set "/run/gitea/app.ini" server HTTP_ADDR ""
crudini --set "/run/gitea/app.ini" server HTTP_PORT "3000" crudini --set "/run/gitea/app.ini" server HTTP_PORT "3000"
@@ -84,21 +109,22 @@ crudini --set "/run/gitea/app.ini" server SSH_PORT "${SSH_PORT}"
crudini --set "/run/gitea/app.ini" server APP_DATA_PATH "/app/data/appdata" crudini --set "/run/gitea/app.ini" server APP_DATA_PATH "/app/data/appdata"
crudini --set "/run/gitea/app.ini" repository ROOT "/app/data/repository" crudini --set "/run/gitea/app.ini" repository ROOT "/app/data/repository"
crudini --set "/run/gitea/app.ini" repository.upload TEMP_PATH "/run/gitea/tmp/uploads" crudini --set "/run/gitea/app.ini" repository.upload TEMP_PATH "/run/gitea/tmp/uploads"
crudini --set "/run/gitea/app.ini" mailer HOST "${MAIL_SMTP_SERVER}:${MAIL_SMTPS_PORT}" crudini --set "/run/gitea/app.ini" mailer HOST "${CLOUDRON_MAIL_SMTP_SERVER}:${CLOUDRON_MAIL_SMTPS_PORT}"
crudini --set "/run/gitea/app.ini" mailer USER "${MAIL_SMTP_USERNAME}" crudini --set "/run/gitea/app.ini" mailer USER "${CLOUDRON_MAIL_SMTP_USERNAME}"
crudini --set "/run/gitea/app.ini" mailer PASSWD "${MAIL_SMTP_PASSWORD}" crudini --set "/run/gitea/app.ini" mailer PASSWD "${CLOUDRON_MAIL_SMTP_PASSWORD}"
crudini --set "/run/gitea/app.ini" mailer FROM "${MAIL_FROM}" crudini --set "/run/gitea/app.ini" mailer FROM "${CLOUDRON_MAIL_FROM}"
crudini --set "/run/gitea/app.ini" mailer SKIP_VERIFY "true" crudini --set "/run/gitea/app.ini" mailer SKIP_VERIFY "true"
crudini --set "/run/gitea/app.ini" security INSTALL_LOCK "true" crudini --set "/run/gitea/app.ini" security INSTALL_LOCK "true"
crudini --set "/run/gitea/app.ini" log MODE "console" crudini --set "/run/gitea/app.ini" log MODE "console"
crudini --set "/run/gitea/app.ini" log ROOT_PATH "/run/gitea" crudini --set "/run/gitea/app.ini" log ROOT_PATH "/run/gitea"
crudini --set "/run/gitea/app.ini" indexer ISSUE_INDEXER_PATH "/app/data/appdata/indexers/issues.bleve" crudini --set "/run/gitea/app.ini" indexer ISSUE_INDEXER_PATH "/app/data/appdata/indexers/issues.bleve"
echo "==> Creating dirs and changing permissions"
mkdir -p /app/data/repository /app/data/ssh /app/data/custom mkdir -p /app/data/repository /app/data/ssh /app/data/custom
chown -R git:git /app/data /run/gitea chown -R git:git /app/data /run/gitea
( setup_ldap_source ) & # this expects app.ini to be available
( setup_auth ) &
exec /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i Gitea exec /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i Gitea

1938
test/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -9,17 +9,15 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"ejs": "^2.3.4", "chromedriver": "^76.0.0",
"expect.js": "^0.3.1", "expect.js": "^0.3.1",
"mkdirp": "^0.5.1", "mocha": "^6.1.4",
"mocha": "^2.3.4", "rimraf": "^2.6.3",
"rimraf": "^2.4.4", "superagent": "^5.0.5"
"superagent": "^1.4.0"
}, },
"dependencies": { "dependencies": {
"chromedriver": "^2.38.2", "selenium-server-standalone-jar": "^3.141.5",
"selenium-server-standalone-jar": "^3.3.1", "selenium-webdriver": "^3.6.0",
"selenium-webdriver": "^3.3.0",
"superagent": "^1.8.5" "superagent": "^1.8.5"
} }
} }

View File

@@ -12,14 +12,11 @@
require('chromedriver'); require('chromedriver');
var execSync = require('child_process').execSync, var execSync = require('child_process').execSync,
ejs = require('ejs'),
expect = require('expect.js'), expect = require('expect.js'),
fs = require('fs'), fs = require('fs'),
mkdirp = require('mkdirp'),
path = require('path'), path = require('path'),
rimraf = require('rimraf'), rimraf = require('rimraf'),
superagent = require('superagent'), superagent = require('superagent');
webdriver = require('selenium-webdriver');
var by = require('selenium-webdriver').By, var by = require('selenium-webdriver').By,
until = require('selenium-webdriver').until, until = require('selenium-webdriver').until,
@@ -31,16 +28,18 @@ describe('Application life cycle test', function () {
this.timeout(0); this.timeout(0);
var server, browser = new Builder().forBrowser('chrome').build(); var server, browser = new Builder().forBrowser('chrome').build();
var LOCATION = 'test'; var LOCATION = 'test';
var SSH_PORT = 29420;
var repodir = '/tmp/testrepo'; var repodir = '/tmp/testrepo';
var app, reponame = 'testrepo'; var app, reponame = 'testrepo';
var username = process.env.USERNAME; var username = process.env.USERNAME;
var password = process.env.PASSWORD; var password = process.env.PASSWORD;
var TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 5000; var TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 5000;
var email, token; var email = process.env.EMAIL, token;
before(function (done) { before(function (done) {
if (!process.env.USERNAME) return done(new Error('USERNAME env var not set')); if (!process.env.USERNAME) return done(new Error('USERNAME env var not set'));
if (!process.env.PASSWORD) return done(new Error('PASSWORD env var not set')); if (!process.env.PASSWORD) return done(new Error('PASSWORD env var not set'));
if (!process.env.EMAIL) return done(new Error('EMAIL env var not set'));
var seleniumJar= require('selenium-server-standalone-jar'); var seleniumJar= require('selenium-server-standalone-jar');
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer; var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
@@ -57,12 +56,12 @@ describe('Application life cycle test', function () {
done(); done();
}); });
function waitForUrl(url, done) { function waitForUrl(url) {
browser.wait(function () { return browser.wait(function () {
return browser.getCurrentUrl().then(function (currentUrl) { return browser.getCurrentUrl().then(function (currentUrl) {
return currentUrl === url; return currentUrl === url;
}); });
}, TIMEOUT).then(function () { done(); }); }, TIMEOUT);
} }
function getAppInfo() { function getAppInfo() {
@@ -127,11 +126,13 @@ return done();
}).then(function () { }).then(function () {
return browser.findElement(by.xpath('//button[contains(text(), "Commit Changes")]')).click(); return browser.findElement(by.xpath('//button[contains(text(), "Commit Changes")]')).click();
}).then(function () { }).then(function () {
waitForUrl('https://' + app.fqdn + '/' + username + '/' + reponame + '/src/branch/master/newfile', done); return waitForUrl('https://' + app.fqdn + '/' + username + '/' + reponame + '/src/branch/master/newfile');
}).then(function () {
done();
}); });
} }
function login(done) { function login(username, password, done) {
browser.get('https://' + app.fqdn + '/user/login').then(function () { browser.get('https://' + app.fqdn + '/user/login').then(function () {
return browser.findElement(by.id('user_name')).sendKeys(username); return browser.findElement(by.id('user_name')).sendKeys(username);
}).then(function () { }).then(function () {
@@ -145,6 +146,18 @@ return done();
}); });
} }
function adminLogin(done) {
login('root', 'changeme', done);
}
function logout(done) {
browser.get('https://' + app.fqdn + '/user/logout').then(function () {
return waitForUrl('https://' + app.fqdn + '/explore/repos');
}).then(function () {
done();
});
}
function addPublicKey(done) { function addPublicKey(done) {
var publicKey = fs.readFileSync(__dirname + '/id_rsa.pub', 'utf8'); var publicKey = fs.readFileSync(__dirname + '/id_rsa.pub', 'utf8');
@@ -210,7 +223,7 @@ return done();
}).then(function () { }).then(function () {
return browser.findElement(by.id('repo-clone-url')).getAttribute('value'); return browser.findElement(by.id('repo-clone-url')).getAttribute('value');
}).then(function (cloneUrl) { }).then(function (cloneUrl) {
expect(cloneUrl).to.be('ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git'); expect(cloneUrl).to.be(`ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame}.git`);
done(); done();
}); });
} }
@@ -219,14 +232,14 @@ return done();
rimraf.sync(repodir); rimraf.sync(repodir);
var env = Object.create(process.env); var env = Object.create(process.env);
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh'; env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
execSync('git clone ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git ' + repodir, { env: env }); execSync(`git clone ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame}.git ${repodir}`, { env: env });
done(); done();
} }
function pushFile(done) { function pushFile(done) {
var env = Object.create(process.env); var env = Object.create(process.env);
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh'; env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
execSync('touch newfile && git add newfile && git commit -a -mx && git push ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + ' master', execSync(`touch newfile && git add newfile && git commit -a -mx && git push ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame} master`,
{ env: env, cwd: repodir }); { env: env, cwd: repodir });
rimraf.sync('/tmp/testrepo'); rimraf.sync('/tmp/testrepo');
done(); done();
@@ -254,7 +267,7 @@ return done();
} }
function sendMail(done) { function sendMail(done) {
browser.get('https://' + app.fqdn + '/admin/config').then(function () { browser.get(`https://${app.fqdn}/admin/config`).then(function () {
var button = browser.findElement(by.xpath('//button[@id="test-mail-btn"]')); var button = browser.findElement(by.xpath('//button[@id="test-mail-btn"]'));
return browser.executeScript('arguments[0].scrollIntoView(true)', button); return browser.executeScript('arguments[0].scrollIntoView(true)', button);
}).then(function () { }).then(function () {
@@ -275,7 +288,7 @@ return done();
it('can login', function (done) { it('can login', function (done) {
var inspect = JSON.parse(execSync('cloudron inspect')); var inspect = JSON.parse(execSync('cloudron inspect'));
superagent.post('https://' + inspect.apiEndpoint + '/api/v1/developer/login').send({ superagent.post(`https://${inspect.apiEndpoint}/api/v1/developer/login`).send({
username: username, username: username,
password: password password: password
}).end(function (error, result) { }).end(function (error, result) {
@@ -284,7 +297,7 @@ return done();
token = result.body.accessToken; token = result.body.accessToken;
superagent.get('https://' + inspect.apiEndpoint + '/api/v1/profile') superagent.get(`https://${inspect.apiEndpoint}/api/v1/profile`)
.query({ access_token: token }).end(function (error, result) { .query({ access_token: token }).end(function (error, result) {
if (error) return done(error); if (error) return done(error);
if (result.statusCode !== 200) return done(new Error('Get profile failed with status ' + result.statusCode)); if (result.statusCode !== 200) return done(new Error('Get profile failed with status ' + result.statusCode));
@@ -296,7 +309,7 @@ return done();
}); });
it('install app', function () { it('install app', function () {
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync(`cloudron install --new --wait --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
}); });
it('can get app information', getAppInfo); it('can get app information', getAppInfo);
@@ -309,8 +322,11 @@ return done();
}); });
}); });
it('can login', login); it('can admin login', adminLogin);
it('can send mail', sendMail); it('can send mail', sendMail);
it('can logout', logout);
it('can login', login.bind(null, username, password));
it('can set avatar', setAvatar); it('can set avatar', setAvatar);
it('can get avatar', checkAvatar); it('can get avatar', checkAvatar);
@@ -333,7 +349,7 @@ return done();
done(); done();
}); });
it('can login', login); xit('can login', login.bind(null, username, password)); // no need to relogin since session persists
it('displays correct clone url', checkCloneUrl); it('displays correct clone url', checkCloneUrl);
it('can clone the url', cloneRepo); it('can clone the url', cloneRepo);
it('file exists in repo', fileExists); it('file exists in repo', fileExists);
@@ -346,7 +362,7 @@ return done();
execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
}); });
it('can login', login); it('can login', login.bind(null, username, password));
it('can get avatar', checkAvatar); it('can get avatar', checkAvatar);
it('can clone the url', cloneRepo); it('can clone the url', cloneRepo);
it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); }); it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); });
@@ -364,7 +380,7 @@ return done();
}); });
}); });
it('can login', login); it('can login', login.bind(null, username, password));
it('can get avatar', checkAvatar); it('can get avatar', checkAvatar);
it('displays correct clone url', checkCloneUrl); it('displays correct clone url', checkCloneUrl);
it('can clone the url', cloneRepo); it('can clone the url', cloneRepo);
@@ -380,13 +396,13 @@ return done();
// check if the _first_ login via email succeeds // check if the _first_ login via email succeeds
it('can login via email', function (done) { it('can login via email', function (done) {
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync(`cloudron install --new --wait --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
var inspect = JSON.parse(execSync('cloudron inspect')); var inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0]; app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
expect(app).to.be.an('object'); expect(app).to.be.an('object');
login(function (error) { login(email, password, function (error) {
if (error) return done(error); if (error) return done(error);
// ensure we don't hit NXDOMAIN in the mean time // ensure we don't hit NXDOMAIN in the mean time
@@ -397,13 +413,33 @@ return done();
}); });
}); });
// No SSO
it('install app (no sso)', function () {
execSync(`cloudron install --new --wait --no-sso --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
it('can get app information', function () {
var inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
expect(app).to.be.an('object');
});
it('can admin login (no sso)', adminLogin);
it('can logout', logout);
it('uninstall app (no sso)', function () {
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
// test update // test update
it('can install app', function () { it('can install app', function () {
execSync('cloudron install --new --wait --appstore-id ' + app.manifest.id + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync(`cloudron install --new --wait --appstore-id ${app.manifest.id} --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
}); });
it('can get app information', getAppInfo); it('can get app information', getAppInfo);
it('can login', login); it('can login', login.bind(null, username, password));
it('can set avatar', setAvatar); it('can set avatar', setAvatar);
it('can get avatar', checkAvatar); it('can get avatar', checkAvatar);
it('can add public key', addPublicKey); it('can add public key', addPublicKey);
@@ -415,8 +451,11 @@ return done();
execSync('cloudron install --wait --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync('cloudron install --wait --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
}); });
it('can login', login); xit('can admin login', adminLogin);
it('can send mail', sendMail); xit('can send mail', sendMail);
xit('can logout', logout);
it('can login', login.bind(null, username, password));
it('can get avatar', checkAvatar); it('can get avatar', checkAvatar);
it('can clone the url', cloneRepo); it('can clone the url', cloneRepo);
it('file exists in cloned repo', fileExists); it('file exists in cloned repo', fileExists);