From ea0ce0ebe8336d932cd522569c36a65c025f87cc Mon Sep 17 00:00:00 2001 From: Noah Lee Date: Fri, 24 May 2024 11:37:24 +0900 Subject: [PATCH 1/4] chore: Replace into MIT license --- LICENSE | 47 ++++------------------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/LICENSE b/LICENSE index 37c97e6b..558d8a80 100644 --- a/LICENSE +++ b/LICENSE @@ -1,46 +1,7 @@ -Copyright 2021 Gitploy.IO, Inc. +Copyright 2024 Gitploy.io -The Gitploy Community Edition is licensed under the Apache License, -Version 2.0 (the "Apache License"). +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - http://www.apache.org/licenses/LICENSE-2.0 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -The source files in this repository are under the Apache License -basically, but some files are under the Gitploy Non-Commercial License. -The header of files indicating which license they are under. - -The Gitploy Enterprise Edition is licensed under the Gitploy -Non-Commercial License (the "Non-Commercial License"). A copy of -the Non-Commercial License is provided below. - -The BUILDING_OSS file provides -instructions for creating the Community Edition distribution -subject to the terms of the Apache License. - ------------------------------------------------------------------ - -Gitploy Non-Commercial License - -Contributor: Gitploy.IO, Inc. - -Source Code: https://github.com/gitploy-io/gitploy - -This license lets you use and share this software for free, -under the count of user limit on commercial use. Specifically: - -If you follow the rules below, you may do everything with this -software that would otherwise infringe either the contributor's -copyright in it. - -1. You must limit use of this software in any manner primarily - intended for commercial advantage or private monetary compensation. - This limit does not apply to use in developing feedback or extensions - that you contribute back to those giving this license. - -2. Ensure everyone who gets a copy of this software from you, in - source code, gets the text of this license. - -**This software comes as is, without any warranty at all. As far -as the law allows, the contributor will not be liable for any -damages related to this software or this license, for any kind of -legal claim.** +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file From 232ac2d085dfb8c5970f2a7d97ff1f6c87af708d Mon Sep 17 00:00:00 2001 From: Noah Lee Date: Fri, 24 May 2024 11:37:29 +0900 Subject: [PATCH 2/4] feat: Update license limits to allow infinite members and deployments --- model/extent/license.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/model/extent/license.go b/model/extent/license.go index 33c6b804..d7176943 100644 --- a/model/extent/license.go +++ b/model/extent/license.go @@ -1,10 +1,15 @@ package extent -import "time" +import ( + "math" + "time" +) const ( TrialMemberLimit = 5 TrialDeploymentLimit = 5000 + InfiniteMemberLimit = math.MaxInt + InfiniteDeploymentLimit = math.MaxInt ) const ( @@ -47,9 +52,9 @@ func NewTrialLicense(memberCnt, deploymentCnt int) *License { return &License{ Kind: LicenseKindTrial, MemberCount: memberCnt, - MemberLimit: TrialMemberLimit, + MemberLimit: InfiniteMemberLimit, DeploymentCount: deploymentCnt, - DeploymentLimit: TrialDeploymentLimit, + DeploymentLimit: InfiniteMemberLimit, } } @@ -57,7 +62,7 @@ func NewStandardLicense(memberCnt int, d *SigningData) *License { return &License{ Kind: LicenseKindStandard, MemberCount: memberCnt, - MemberLimit: d.MemberLimit, + MemberLimit: InfiniteMemberLimit, DeploymentCount: -1, ExpiredAt: d.ExpiredAt, } From 369963bc6e10e3712876a18b77a0a71d829dc3e9 Mon Sep 17 00:00:00 2001 From: Noah Lee Date: Fri, 24 May 2024 14:00:40 +0900 Subject: [PATCH 3/4] chore: Update CONTRIBUTING.md with authorization instructions --- CONTRIBUTING.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a73ee5bd..3e1862a1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,8 +38,6 @@ GITPLOY_GITHUB_CLIENT_SECRET=XXXXXXXXXXXXX GITPLOY_STORE_SOURCE=file:./sqlite3.db?cache=shared&_fk=1 ``` -Note that if you want to interact with GitHub in the local environment, you should install tunneling tools such as [ngork](https://ngrok.com/) and expose your local server. - 3\. Run the server: ``` @@ -71,3 +69,22 @@ REACT_APP_GITPLOY_SERVER=http://localhost ``` npm start ``` + +### Authorization + +1\. Run with ngrok + +Connect to the public host via [ngrok](https://ngrok.com/) to authorize with GitHub OAuth. + +```shell +ngrok http 80 +``` + +2\. Configure GitHub OAuth Apps + +Configure the Homepage URL and Authorization callback URLs with the public host which generated by ngrok. + +3\. Access the index page + +Access the index page of server with the browser. You can find the user is created after authorization. + From 6ec78e94f80d00a744a36404c0a185a4dac03bc8 Mon Sep 17 00:00:00 2001 From: Noah Lee Date: Fri, 24 May 2024 14:03:36 +0900 Subject: [PATCH 4/4] chore: Remove license limit checks in middleware_test.go and license_test.go --- internal/server/api/shared/middleware_test.go | 27 ------------------- model/extent/license_test.go | 18 ------------- 2 files changed, 45 deletions(-) diff --git a/internal/server/api/shared/middleware_test.go b/internal/server/api/shared/middleware_test.go index aa63f30e..04b1121b 100644 --- a/internal/server/api/shared/middleware_test.go +++ b/internal/server/api/shared/middleware_test.go @@ -42,33 +42,6 @@ func TestMiddleware_IsLicenseExpired(t *testing.T) { } }) - t.Run("Return 402 error when the count of member is over the limit.", func(t *testing.T) { - ctrl := gomock.NewController(t) - m := mock.NewMockInteractor(ctrl) - - m. - EXPECT(). - GetLicense(gomock.Any()). - Return(extent.NewTrialLicense(extent.TrialMemberLimit+1, extent.TrialDeploymentLimit), nil) - - gin.SetMode(gin.ReleaseMode) - router := gin.New() - - lm := NewMiddleware(m) - router.GET("/repos", lm.IsLicenseExpired(), func(c *gin.Context) { - c.Status(http.StatusOK) - }) - - req, _ := http.NewRequest("GET", "/repos", nil) - w := httptest.NewRecorder() - - router.ServeHTTP(w, req) - - if w.Code != http.StatusPaymentRequired { - t.Fatalf("IsLicenseExpired = %v, wanted %v", w.Code, http.StatusPaymentRequired) - } - }) - t.Run("Return 200 when the count of member is under the limit.", func(t *testing.T) { ctrl := gomock.NewController(t) m := mock.NewMockInteractor(ctrl) diff --git a/model/extent/license_test.go b/model/extent/license_test.go index 32282bb3..e8864382 100644 --- a/model/extent/license_test.go +++ b/model/extent/license_test.go @@ -15,24 +15,6 @@ func TestLicense_IsOverLimit(t *testing.T) { } }) - t.Run("Return true when the trial license is over the member limit.", func(t *testing.T) { - l := NewTrialLicense(TrialMemberLimit+1, 0) - - expected := true - if finished := l.IsOverLimit(); finished != expected { - t.Fatalf("IsOverLimit = %v, wanted %v", finished, expected) - } - }) - - t.Run("Return true when the trial license is over the deployment limit.", func(t *testing.T) { - l := NewTrialLicense(5, TrialDeploymentLimit+1) - - expected := true - if finished := l.IsOverLimit(); finished != expected { - t.Fatalf("IsOverLimit = %v, wanted %v", finished, expected) - } - }) - t.Run("Return false when the trial license is less than or equal to the limit.", func(t *testing.T) { l := NewTrialLicense(TrialMemberLimit, TrialDeploymentLimit)