Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8bda404e
Commit
8bda404e
authored
Jan 09, 2020
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@master
parent
afa0ab92
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
349 additions
and
25 deletions
+349
-25
GITALY_SERVER_VERSION
GITALY_SERVER_VERSION
+1
-1
app/models/appearance.rb
app/models/appearance.rb
+5
-0
app/services/akismet_service.rb
app/services/akismet_service.rb
+10
-7
app/services/ham_service.rb
app/services/ham_service.rb
+3
-1
app/services/spam_service.rb
app/services/spam_service.rb
+2
-1
changelogs/unreleased/feat-appearance-api.yml
changelogs/unreleased/feat-appearance-api.yml
+5
-0
changelogs/unreleased/mk-add-geo-node-name-to-check-task.yml
changelogs/unreleased/mk-add-geo-node-name-to-check-task.yml
+5
-0
changelogs/unreleased/pokstad1-bump-gitaly-1-80-0.yml
changelogs/unreleased/pokstad1-bump-gitaly-1-80-0.yml
+5
-0
doc/administration/geo/replication/troubleshooting.md
doc/administration/geo/replication/troubleshooting.md
+17
-14
doc/api/api_resources.md
doc/api/api_resources.md
+1
-0
doc/api/appearance.md
doc/api/appearance.md
+80
-0
doc/ssh/README.md
doc/ssh/README.md
+1
-1
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/appearance.rb
lib/api/appearance.rb
+47
-0
lib/api/entities.rb
lib/api/entities.rb
+24
-0
spec/requests/api/appearance_spec.rb
spec/requests/api/appearance_spec.rb
+142
-0
No files found.
GITALY_SERVER_VERSION
View file @
8bda404e
1.
79
.0
1.
80
.0
app/models/appearance.rb
View file @
8bda404e
...
...
@@ -18,6 +18,11 @@ class Appearance < ApplicationRecord
validate
:single_appearance_row
,
on: :create
default_value_for
:title
,
''
default_value_for
:description
,
''
default_value_for
:new_project_guidelines
,
''
default_value_for
:header_message
,
''
default_value_for
:footer_message
,
''
default_value_for
:message_background_color
,
'#E75E40'
default_value_for
:message_font_color
,
'#FFFFFF'
default_value_for
:email_header_and_footer_enabled
,
false
...
...
app/services/akismet_service.rb
View file @
8bda404e
# frozen_string_literal: true
class
AkismetService
attr_accessor
:
owner
,
:
text
,
:options
attr_accessor
:text
,
:options
def
initialize
(
owner
,
text
,
options
=
{})
@owner
=
owner
def
initialize
(
owner_name
,
owner_email
,
text
,
options
=
{})
@owner_name
=
owner_name
@owner_email
=
owner_email
@text
=
text
@options
=
options
end
...
...
@@ -16,8 +17,8 @@ class AkismetService
type:
'comment'
,
text:
text
,
created_at:
DateTime
.
now
,
author:
owner
.
name
,
author_email:
owner
.
email
,
author:
owner
_
name
,
author_email:
owner
_
email
,
referrer:
options
[
:referrer
]
}
...
...
@@ -40,6 +41,8 @@ class AkismetService
private
attr_accessor
:owner_name
,
:owner_email
def
akismet_client
@akismet_client
||=
::
Akismet
::
Client
.
new
(
Gitlab
::
CurrentSettings
.
akismet_api_key
,
Gitlab
.
config
.
gitlab
.
url
)
...
...
@@ -55,8 +58,8 @@ class AkismetService
params
=
{
type:
'comment'
,
text:
text
,
author:
owner
.
name
,
author_email:
owner
.
email
author:
owner
_
name
,
author_email:
owner
_
email
}
begin
...
...
app/services/ham_service.rb
View file @
8bda404e
...
...
@@ -18,8 +18,10 @@ class HamService
private
def
akismet
user
=
spam_log
.
user
@akismet
||=
AkismetService
.
new
(
spam_log
.
user
,
user
.
name
,
user
.
email
,
spam_log
.
text
,
ip_address:
spam_log
.
source_ip
,
user_agent:
spam_log
.
user_agent
...
...
app/services/spam_service.rb
View file @
8bda404e
...
...
@@ -56,7 +56,8 @@ class SpamService
def
akismet
@akismet
||=
AkismetService
.
new
(
spammable_owner
,
spammable_owner
.
name
,
spammable_owner
.
email
,
spammable
.
spammable_text
,
options
)
...
...
changelogs/unreleased/feat-appearance-api.yml
0 → 100644
View file @
8bda404e
---
title
:
Implement application appearance API endpoint
merge_request
:
20674
author
:
Fabio Huser
type
:
added
changelogs/unreleased/mk-add-geo-node-name-to-check-task.yml
0 → 100644
View file @
8bda404e
---
title
:
'
Geo:
Check
current
node
in
gitlab:geo:check
Rake
task'
merge_request
:
22436
author
:
type
:
added
changelogs/unreleased/pokstad1-bump-gitaly-1-80-0.yml
0 → 100644
View file @
8bda404e
---
title
:
Update Gitaly to v1.80.0
merge_request
:
22654
author
:
type
:
other
doc/administration/geo/replication/troubleshooting.md
View file @
8bda404e
...
...
@@ -51,6 +51,7 @@ Checking Geo ...
GitLab Geo is available ... yes
GitLab Geo is enabled ... yes
This machine's Geo node name matches a database record ... yes, found a secondary node named "Shanghai"
GitLab Geo secondary database is correctly configured ... yes
Database replication enabled? ... yes
Database replication working? ... yes
...
...
@@ -115,34 +116,36 @@ Any **secondary** nodes should point only to read-only instances.
#### Can Geo detect the current node correctly?
Geo finds the current machine's name in
`/etc/gitlab/gitlab.rb`
by:
Geo finds the current machine's
Geo node
name in
`/etc/gitlab/gitlab.rb`
by:
-
Using the
`gitlab_rails['geo_node_name']`
setting.
-
If that is not defined, using the
`external_url`
setting.
To get a machine's name, run:
```
sh
sudo
gitlab-rails runner
"puts GeoNode.current_node_name"
```
This name is used to look up the node with the same
**Name**
in
**Admin Area > Geo**
.
To check if current machine is correctly finding its node:
To check if the current machine has a node name that matches a node in the
database, run the check task:
```
sh
sudo
gitlab-ra
ils runner
"puts Gitlab::Geo.current_node.inspect"
sudo
gitlab-ra
ke gitlab:geo:check
```
and expect something like:
It displays the current machine's node name and whether the matching database
record is a
**primary**
or
**secondary**
node.
```
ruby
#<GeoNode id: 2, schema: "https", host: "gitlab.example.com", port: 443, relative_url_root: "", primary: false, ...>
```
This machine's Geo node name matches a database record ... yes, found a secondary node named "Shanghai"
```
By running the command above,
`primary`
should be
`true`
when executed in
the
**primary**
node, and
`false`
on any
**secondary**
node.
```
This machine's Geo node name matches a database record ... no
Try fixing it:
You could add or update a Geo node database record, setting the name to "https://example.com/".
Or you could set this machine's Geo node name to match the name of an existing database record: "London", "Shanghai"
For more information see:
doc/administration/geo/replication/troubleshooting.md#can-geo-detect-the-current-node-correctly
```
## Fixing errors found when running the Geo check rake task
...
...
doc/api/api_resources.md
View file @
8bda404e
...
...
@@ -105,6 +105,7 @@ The following API resources are available outside of project and group contexts
| Resource | Available endpoints |
|:--------------------------------------------------|:------------------------------------------------------------------------|
|
[
Appearance
](
appearance.md
)
**(CORE ONLY)**
|
`/application/appearance`
|
|
[
Applications
](
applications.md
)
|
`/applications`
|
|
[
Audit Events
](
audit_events.md
)
**(PREMIUM ONLY)**
|
`/audit_events`
|
|
[
Avatar
](
avatar.md
)
|
`/avatar`
|
...
...
doc/api/appearance.md
0 → 100644
View file @
8bda404e
# Appearance API **(CORE ONLY)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/16647) in GitLab 12.7.
Appearance API allows you to maintain GitLab's appearance as if using the GitLab UI at
`/admin/appearance`
. The API requires administrator privileges.
## Get current appearance configuration
List the current appearance configuration of the GitLab instance.
```
GET /application/appearance
```
```
bash
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
https://gitlab.example.com/api/v4/application/appearance
```
Example response:
```
json
{
"title"
:
"GitLab Test Instance"
,
"description"
:
"gitlab-test.example.com"
,
"logo"
:
"/uploads/-/system/appearance/logo/1/logo.png"
,
"header_logo"
:
"/uploads/-/system/appearance/header_logo/1/header.png"
,
"favicon"
:
"/uploads/-/system/appearance/favicon/1/favicon.png"
,
"new_project_guidelines"
:
"Please read the FAQs for help."
,
"header_message"
:
""
,
"footer_message"
:
""
,
"message_background_color"
:
"#e75e40"
,
"message_font_color"
:
"#ffffff"
,
"email_header_and_footer_enabled"
:
false
}
```
## Change appearance configuration
Use an API call to modify GitLab instance appearance configuration.
```
PUT /application/appearance
```
| Attribute | Type | Required | Description |
| --------------------------------- | ------- | -------- | ----------- |
|
`title`
| string | no | Instance title on the sign in / sign up page
|
`description`
| string | no | Markdown text shown on the sign in / sign up page
|
`logo`
| mixed | no | Instance image used on the sign in / sign up page
|
`header_logo`
| mixed | no | Instance image used for the main navigation bar
|
`favicon`
| mixed | no | Instance favicon in .ico/.png format
|
`new_project_guidelines`
| string | no | Markdown text shown on the new project page
|
`header_message`
| string | no | Message within the system header bar
|
`footer_message`
| string | no | Message within the system footer bar
|
`message_background_color`
| string | no | Background color for the system header / footer bar
|
`message_font_color`
| string | no | Font color for the system header / footer bar
|
`email_header_and_footer_enabled`
| boolean | no | Add header and footer to all outgoing emails if enabled
```
bash
curl
--request
PUT
--header
"PRIVATE-TOKEN: <your_access_token>"
https://gitlab.example.com/api/v4/application/appearance?email_header_and_footer_enabled
=
true
&header_message
=
test
```
Example response:
```
json
{
"title"
:
"GitLab Test Instance"
,
"description"
:
"gitlab-test.example.com"
,
"logo"
:
"/uploads/-/system/appearance/logo/1/logo.png"
,
"header_logo"
:
"/uploads/-/system/appearance/header_logo/1/header.png"
,
"favicon"
:
"/uploads/-/system/appearance/favicon/1/favicon.png"
,
"new_project_guidelines"
:
"Please read the FAQs for help."
,
"header_message"
:
"test"
,
"footer_message"
:
""
,
"message_background_color"
:
"#e75e40"
,
"message_font_color"
:
"#ffffff"
,
"email_header_and_footer_enabled"
:
true
}
```
doc/ssh/README.md
View file @
8bda404e
...
...
@@ -183,7 +183,7 @@ Now, it's time to add the newly created public key to your GitLab account.
1.
Add your
**public**
SSH key to your GitLab account by:
1.
Clicking your avatar in the upper right corner and selecting
**Settings**
.
1.
Navigating to
**SSH Keys**
and pasting your
**public**
key
in
the
**Key**
field. If you:
1.
Navigating to
**SSH Keys**
and pasting your
**public**
key
from the clipboard into
the
**Key**
field. If you:
-
Created the key with a comment, this will appear in the
**Title**
field.
-
Created the key without a comment, give your key an identifiable title like _Work Laptop_ or _Home Workstation_.
1.
Click the
**Add key**
button.
...
...
lib/api/api.rb
View file @
8bda404e
...
...
@@ -104,6 +104,7 @@ module API
# Keep in alphabetical order
mount
::
API
::
AccessRequests
mount
::
API
::
Appearance
mount
::
API
::
Applications
mount
::
API
::
Avatar
mount
::
API
::
AwardEmoji
...
...
lib/api/appearance.rb
0 → 100644
View file @
8bda404e
# frozen_string_literal: true
module
API
class
Appearance
<
Grape
::
API
before
{
authenticated_as_admin!
}
helpers
do
def
current_appearance
@current_appearance
||=
(
::
Appearance
.
current
||
::
Appearance
.
new
)
end
end
desc
'Get the current appearance'
do
success
Entities
::
Appearance
end
get
"application/appearance"
do
present
current_appearance
,
with:
Entities
::
Appearance
end
desc
'Modify appearance'
do
success
Entities
::
Appearance
end
params
do
optional
:title
,
type:
String
,
desc:
'Instance title on the sign in / sign up page'
optional
:description
,
type:
String
,
desc:
'Markdown text shown on the sign in / sign up page'
# TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960
optional
:logo
,
type:
File
,
desc:
'Instance image used on the sign in / sign up page'
# rubocop:disable Scalability/FileUploads
optional
:header_logo
,
type:
File
,
desc:
'Instance image used for the main navigation bar'
# rubocop:disable Scalability/FileUploads
optional
:favicon
,
type:
File
,
desc:
'Instance favicon in .ico/.png format'
# rubocop:disable Scalability/FileUploads
optional
:new_project_guidelines
,
type:
String
,
desc:
'Markmarkdown text shown on the new project page'
optional
:header_message
,
type:
String
,
desc:
'Message within the system header bar'
optional
:footer_message
,
type:
String
,
desc:
'Message within the system footer bar'
optional
:message_background_color
,
type:
String
,
desc:
'Background color for the system header / footer bar'
optional
:message_font_color
,
type:
String
,
desc:
'Font color for the system header / footer bar'
optional
:email_header_and_footer_enabled
,
type:
Boolean
,
desc:
'Add header and footer to all outgoing emails if enabled'
end
put
"application/appearance"
do
attrs
=
declared_params
(
include_missing:
false
)
if
current_appearance
.
update
(
attrs
)
present
current_appearance
,
with:
Entities
::
Appearance
else
render_validation_error!
(
current_appearance
)
end
end
end
end
lib/api/entities.rb
View file @
8bda404e
...
...
@@ -1343,6 +1343,30 @@ module API
expose
:allow_local_requests_from_web_hooks_and_services
,
as: :allow_local_requests_from_hooks_and_services
end
class
Appearance
<
Grape
::
Entity
expose
:title
expose
:description
expose
:logo
do
|
appearance
,
options
|
appearance
.
logo
.
url
end
expose
:header_logo
do
|
appearance
,
options
|
appearance
.
header_logo
.
url
end
expose
:favicon
do
|
appearance
,
options
|
appearance
.
favicon
.
url
end
expose
:new_project_guidelines
expose
:header_message
expose
:footer_message
expose
:message_background_color
expose
:message_font_color
expose
:email_header_and_footer_enabled
end
# deprecated old Release representation
class
TagRelease
<
Grape
::
Entity
expose
:tag
,
as: :tag_name
...
...
spec/requests/api/appearance_spec.rb
0 → 100644
View file @
8bda404e
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Appearance
,
'Appearance'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:admin
)
{
create
(
:admin
)
}
describe
"GET /application/appearance"
do
context
'as a non-admin user'
do
it
"returns 403"
do
get
api
(
"/application/appearance"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
context
'as an admin user'
do
it
"returns appearance"
do
get
api
(
"/application/appearance"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
[
'description'
]).
to
eq
(
''
)
expect
(
json_response
[
'email_header_and_footer_enabled'
]).
to
be
(
false
)
expect
(
json_response
[
'favicon'
]).
to
be_nil
expect
(
json_response
[
'footer_message'
]).
to
eq
(
''
)
expect
(
json_response
[
'header_logo'
]).
to
be_nil
expect
(
json_response
[
'header_message'
]).
to
eq
(
''
)
expect
(
json_response
[
'logo'
]).
to
be_nil
expect
(
json_response
[
'message_background_color'
]).
to
eq
(
'#E75E40'
)
expect
(
json_response
[
'message_font_color'
]).
to
eq
(
'#FFFFFF'
)
expect
(
json_response
[
'new_project_guidelines'
]).
to
eq
(
''
)
expect
(
json_response
[
'title'
]).
to
eq
(
''
)
end
end
end
describe
"PUT /application/appearance"
do
context
'as a non-admin user'
do
it
"returns 403"
do
put
api
(
"/application/appearance"
,
user
),
params:
{
title:
"Test"
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
context
'as an admin user'
do
context
"instance basics"
do
it
"allows updating the settings"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
title:
"GitLab Test Instance"
,
description:
"gitlab-test.example.com"
,
new_project_guidelines:
"Please read the FAQs for help."
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
[
'description'
]).
to
eq
(
'gitlab-test.example.com'
)
expect
(
json_response
[
'email_header_and_footer_enabled'
]).
to
be
(
false
)
expect
(
json_response
[
'favicon'
]).
to
be_nil
expect
(
json_response
[
'footer_message'
]).
to
eq
(
''
)
expect
(
json_response
[
'header_logo'
]).
to
be_nil
expect
(
json_response
[
'header_message'
]).
to
eq
(
''
)
expect
(
json_response
[
'logo'
]).
to
be_nil
expect
(
json_response
[
'message_background_color'
]).
to
eq
(
'#E75E40'
)
expect
(
json_response
[
'message_font_color'
]).
to
eq
(
'#FFFFFF'
)
expect
(
json_response
[
'new_project_guidelines'
]).
to
eq
(
'Please read the FAQs for help.'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'GitLab Test Instance'
)
end
end
context
"system header and footer"
do
it
"allows updating the settings"
do
settings
=
{
footer_message:
"This is a Header"
,
header_message:
"This is a Footer"
,
message_font_color:
"#ffffff"
,
message_background_color:
"#009999"
,
email_header_and_footer_enabled:
true
}
put
api
(
"/application/appearance"
,
admin
),
params:
settings
expect
(
response
).
to
have_gitlab_http_status
(
200
)
settings
.
each
do
|
attribute
,
value
|
expect
(
Appearance
.
current
.
public_send
(
attribute
)).
to
eq
(
value
)
end
end
context
"fails on invalid color values"
do
it
"with message_font_color"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
message_font_color:
"No Color"
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'message'
][
'message_font_color'
]).
to
contain_exactly
(
'must be a valid color code'
)
end
it
"with message_background_color"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
message_background_color:
"#1"
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'message'
][
'message_background_color'
]).
to
contain_exactly
(
'must be a valid color code'
)
end
end
end
context
"instance logos"
do
let_it_be
(
:appearance
)
{
create
(
:appearance
)
}
it
"allows updating the image files"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
logo:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
),
header_logo:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
),
favicon:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
)
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'logo'
]).
to
eq
(
"/uploads/-/system/appearance/logo/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'header_logo'
]).
to
eq
(
"/uploads/-/system/appearance/header_logo/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'favicon'
]).
to
eq
(
"/uploads/-/system/appearance/favicon/
#{
appearance
.
id
}
/dk.png"
)
end
context
"fails on invalid color images"
do
it
"with string instead of file"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
logo:
'not-a-file.png'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'error'
]).
to
eq
(
"logo is invalid"
)
end
it
"with .svg file instead of .png"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
favicon:
fixture_file_upload
(
"spec/fixtures/logo_sample.svg"
,
"image/svg"
)
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'message'
][
'favicon'
]).
to
contain_exactly
(
"You are not allowed to upload
\"
svg
\"
files, allowed types: png, ico"
)
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment