diff options
author | Tuomo Ala-Vannesluoma <tuomoav@gmail.com> | 2018-08-07 20:16:26 +0300 |
---|---|---|
committer | Tuomo Ala-Vannesluoma <tuomoav@gmail.com> | 2018-08-07 20:31:02 +0300 |
commit | 90690a9d77b673df5845f05d626ff8f6e75529c7 (patch) | |
tree | eff442c8af947a379badc80018a79efe0df1b0cc /internal/domain | |
parent | 2666c24dacb27efd22ad78044d4f321beed63772 (diff) |
Make private pages public if gitlab and pages is ran without access control, add support for custom domains for which auth is proxied via gitlab pages domain
Diffstat (limited to 'internal/domain')
-rw-r--r-- | internal/domain/domain.go | 12 | ||||
-rw-r--r-- | internal/domain/domain_config.go | 10 | ||||
-rw-r--r-- | internal/domain/map_test.go | 1 |
3 files changed, 19 insertions, 4 deletions
diff --git a/internal/domain/domain.go b/internal/domain/domain.go index e32ba097..77429372 100644 --- a/internal/domain/domain.go +++ b/internal/domain/domain.go @@ -133,6 +133,10 @@ func (d *D) IsAccessControlEnabled(r *http.Request) bool { return false } + if d.config != nil { + return d.config.AccessControl + } + project := d.getProject(r) if project != nil { @@ -144,6 +148,14 @@ func (d *D) IsAccessControlEnabled(r *http.Request) bool { // GetID figures out what is the ID of the project user tries to access func (d *D) GetID(r *http.Request) uint64 { + if d == nil { + return 0 + } + + if d.config != nil { + return d.config.ID + } + project := d.getProject(r) if project != nil { diff --git a/internal/domain/domain_config.go b/internal/domain/domain_config.go index 672f939c..2ab2ce6c 100644 --- a/internal/domain/domain_config.go +++ b/internal/domain/domain_config.go @@ -8,10 +8,12 @@ import ( ) type domainConfig struct { - Domain string - Certificate string - Key string - HTTPSOnly bool `json:"https_only"` + Domain string + Certificate string + Key string + HTTPSOnly bool `json:"https_only"` + ID uint64 `json:"id"` + AccessControl bool `json:"access_control"` } type domainsConfig struct { diff --git a/internal/domain/map_test.go b/internal/domain/map_test.go index f20f98bd..45658e95 100644 --- a/internal/domain/map_test.go +++ b/internal/domain/map_test.go @@ -35,6 +35,7 @@ func TestReadProjects(t *testing.T) { "test.my-domain.com", "test2.my-domain.com", "no.cert.com", + "private.domain.com", } for _, expected := range domains { |