Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 71d55f0

Browse files
authored
move kssh config from kbfs to kv store (#97)
- replace kbfs kssh config code with kvstore code - move shared kbfs.go file into keybaseca - update tests: change keybase fs run_commands to instead use keybase kvstore. lots of linting. - update documentation to not refer to "config files" in KBFS. - update circleci: clean up go linting, and add python linting - some renaming and refactoring
1 parent 3fc2ba1 commit 71d55f0

32 files changed

+1334
-870
lines changed

.circleci/config.yml

+25-20
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
version: 2
2+
commands:
23
jobs:
3-
integration:
4-
machine:
5-
image: circleci/classic:latest
4+
go-lint:
5+
docker:
6+
- image: circleci/golang:1.11
67
steps:
78
- checkout
8-
- run: "./integrationTest.sh"
9+
- run: "! go mod tidy -v 2>&1 | read"
10+
- run: go get github.com/golangci/golangci-lint/cmd/[email protected]
11+
- run: "golangci-lint run"
12+
py-lint:
13+
docker:
14+
- image: circleci/python:3.6.8
15+
steps:
16+
- run: sudo pip3 install isort flake8 black
17+
- run: "isort -rc . --check-only"
18+
- run: "flake8 . --max-line-length=88"
19+
- run: "black . --check"
920
unit:
1021
docker:
1122
- image: circleci/golang:1.11
1223
steps:
1324
- checkout
1425
- run: go test ./...
15-
lint:
16-
docker:
17-
- image: circleci/golang:1.11
26+
integration:
27+
machine:
28+
image: circleci/classic:latest
1829
steps:
1930
- checkout
20-
- run: "! go fmt ./... 2>&1 | read"
21-
- run: "! go vet ./... 2>&1 | read"
22-
- run: go get -u golang.org/x/lint/golint
23-
- run: "! golint ./... 2>&1 | read"
24-
- run: go get golang.org/x/tools/cmd/goimports
25-
- run: "! goimports ./... 2>&1 | read"
26-
- run: "! go mod tidy ./... 2>&1 | read"
27-
- run: go get github.com/golangci/golangci-lint/cmd/[email protected]
28-
- run: "! golangci-lint 2>&1 | read"
31+
- run: "./integrationTest.sh"
2932
sphinx-build:
3033
docker:
3134
- image: circleci/python:2.7.16
@@ -48,15 +51,17 @@ workflows:
4851
version: 2
4952
build:
5053
jobs:
51-
- integration
54+
- go-lint
55+
- py-lint
5256
- unit
53-
- lint
57+
- integration
5458
- sphinx-build
5559
- publish-github-release:
5660
requires:
57-
- integration
61+
- go-lint
62+
- py-lint
5863
- unit
59-
- lint
64+
- integration
6065
filters:
6166
branches:
6267
only: master

.isort.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[settings]
2+
combine_as_imports = true
3+
include_trailing_comma = true
4+
line_length = 88
5+
multi_line_output = 3

docker/Makefile

+14-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77

88
SHELL := /bin/bash
99

10-
.PHONY: build generate serve clean reset-permissions confirm-clean env-file-exists ca-key-exists
10+
.PHONY: build lint go-lint py-lint generate serve clean reset-permissions confirm-clean env-file-exists ca-key-exists
1111

1212
# Build a new docker image for the CA bot
1313
build: reset-permissions
@@ -18,6 +18,18 @@ else
1818
docker build -t ca -f Dockerfile-ca ..
1919
endif
2020

21+
lint: go-lint py-lint
22+
23+
go-lint:
24+
go fmt ../...
25+
go vet ../...
26+
go mod tidy
27+
golangci-lint run ../...
28+
29+
py-lint:
30+
isort -rc ..
31+
flake8 .. --max-line-length=88
32+
black ..
2133

2234
# Generate a new CA key
2335
generate: env-file-exists build
@@ -45,7 +57,7 @@ restart: stop serve
4557

4658
# Delete all kssh config files
4759
clean-kssh: env-file-exists
48-
docker run --init -e FORCE_WRITE=$(FORCE_WRITE) --env-file ./env.list -v $(CURDIR)/example-keybaseca-volume:/mnt:rw ca:latest ./entrypoint-cleanup.sh
60+
docker run --init --env-file ./env.list -v $(CURDIR)/example-keybaseca-volume:/mnt:rw ca:latest ./entrypoint-cleanup.sh
4961

5062
# Delete all CA data
5163
clean: confirm-clean reset-permissions

docker/entrypoint-cleanup.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ chown -R keybase:keybase /mnt
77

88
# Run everything else as the keybase user
99
sudo -i -u keybase bash << EOF
10-
export "FORCE_WRITE=$FORCE_WRITE"
10+
export "TEAMS=$TEAMS"
1111
export "KEYBASE_USERNAME=$KEYBASE_USERNAME"
1212
export "KEYBASE_PAPERKEY=$KEYBASE_PAPERKEY"
1313
nohup bash -c "KEYBASE_RUN_MODE=prod kbfsfuse /keybase | grep -v 'ERROR Mounting the filesystem failed' &"
1414
sleep ${KEYBASE_TIMEOUT:-5}
1515
keybase oneshot
1616
bin/keybaseca --wipe-all-configs
17-
sleep ${KEYBASE_TIMEOUT:-5}
1817
EOF

docs/best_practices.md

+28-21
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,37 @@
22

33
## Teams and Channels
44

5-
The SSH CA bot user needs to have write access in all of the teams used for granting SSH access in order for it to
6-
be able to store config files associated with each team. Since access to a team grants SSH access to servers, it is
7-
recommended to minimize the number of users with admin or owner permissions in the teams. Individual users of kssh
8-
only need to be given the read permission since they do not need to be able to edit or create files associated with
9-
a team.
10-
11-
It is also recommended to mute all notifications in the configured teams in order to minimize the number of notifications
12-
you get.
13-
14-
If you are using other bots in the same teams as the SSH CA bot (or if you wish to have normal conversation in those
15-
teams), you can use the `CHAT_CHANNEL` environment variable in order to configure a specific chat channel for all
16-
SSH CA messages.
5+
The SSH CA bot user needs to have write access in all of the teams used for
6+
granting SSH access in order for it to be able to store kssh client configs
7+
associated with each team. Since access to a team grants SSH access to servers,
8+
it is recommended to minimize the number of users with admin or owner
9+
permissions in the teams. Individual users of kssh only need to be given the
10+
read permission since they do not need to be able to edit or create files
11+
associated with a team.
12+
13+
It is also recommended to mute all notifications in the configured teams in
14+
order to minimize the number of notifications you get.
15+
16+
If you are using other bots in the same teams as the SSH CA bot (or if you wish
17+
to have normal conversation in those teams), you can use the `CHAT_CHANNEL`
18+
environment variable in order to configure a specific chat channel for all SSH
19+
CA messages.
1720

1821
## Network Isolation
1922

20-
Due to the highly sensitive nature of the SSH CA bot, it is recommended to configure firewalls in order to block all
21-
access to the server running the CA bot. It is not recommended to use kssh to access the server of the CA bot itself
22-
in order to make it easier to respond to any outages.
23+
Due to the highly sensitive nature of the SSH CA bot, it is recommended to
24+
configure firewalls in order to block all access to the server running the CA
25+
bot. It is not recommended to use kssh to access the server of the CA bot
26+
itself in order to make it easier to respond to any outages.
2327

2428
## Realms
2529

26-
There are two general approaches one can take when defining realms of servers. The first approach (described in the
27-
getting started directions) is to define realms for staging and production. This approach is useful for the common
28-
scenario where all developers should be given access to the staging environment but only certain people should be given
29-
access to production. The second approach is a more granular approach where you can define realms associated with teams.
30-
For example, one could have a realm of web servers, a realm of database servers, ... where a specific group of people
31-
is responsible for each class of server.
30+
There are two general approaches one can take when defining realms of servers.
31+
The first approach (described in the getting started directions) is to define
32+
realms for staging and production. This approach is useful for the common
33+
scenario where all developers should be given access to the staging environment
34+
but only certain people should be given access to production. The second
35+
approach is a more granular approach where you can define realms associated
36+
with teams. For example, one could have a realm of web servers, a realm of
37+
database servers, ... where a specific group of people is responsible for each
38+
class of server.

docs/conf.py

+29-22
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
# -- Project information -----------------------------------------------------
2020

21-
project = u'Keybase SSH CA Bot'
22-
copyright = u'2019, keybase.io'
23-
author = u'keybase.io'
21+
project = u"Keybase SSH CA Bot"
22+
copyright = u"2019, keybase.io"
23+
author = u"keybase.io"
2424

2525
# The short X.Y version
26-
version = u''
26+
version = u""
2727
# The full version, including alpha/beta/rc tags
28-
release = u''
28+
release = u""
2929

3030

3131
# -- General configuration ---------------------------------------------------
@@ -40,16 +40,16 @@
4040
extensions = ["recommonmark", "sphinx_rtd_theme"]
4141

4242
# Add any paths that contain templates here, relative to this directory.
43-
templates_path = ['_templates']
43+
templates_path = ["_templates"]
4444

4545
# The suffix(es) of source filenames.
4646
# You can specify multiple suffix as a list of string:
4747
#
4848
# source_suffix = ['.rst', '.md']
49-
source_suffix = '.rst'
49+
source_suffix = ".rst"
5050

5151
# The master toctree document.
52-
master_doc = 'index'
52+
master_doc = "index"
5353

5454
# The language for content autogenerated by Sphinx. Refer to documentation
5555
# for a list of supported languages.
@@ -61,7 +61,7 @@
6161
# List of patterns, relative to source directory, that match files and
6262
# directories to ignore when looking for source files.
6363
# This pattern also affects html_static_path and html_extra_path.
64-
exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store']
64+
exclude_patterns = [u"_build", "Thumbs.db", ".DS_Store"]
6565

6666
# The name of the Pygments (syntax highlighting) style to use.
6767
pygments_style = None
@@ -84,7 +84,7 @@
8484
# Add any paths that contain custom static files (such as style sheets) here,
8585
# relative to this directory. They are copied after the builtin static files,
8686
# so a file named "default.css" will overwrite the builtin "default.css".
87-
html_static_path = ['_static']
87+
html_static_path = ["_static"]
8888

8989
# Custom sidebar templates, must be a dictionary that maps document names
9090
# to template names.
@@ -100,7 +100,7 @@
100100
# -- Options for HTMLHelp output ---------------------------------------------
101101

102102
# Output file base name for HTML help builder.
103-
htmlhelp_basename = 'KeybaseSSHCABotdoc'
103+
htmlhelp_basename = "KeybaseSSHCABotdoc"
104104

105105

106106
# -- Options for LaTeX output ------------------------------------------------
@@ -109,15 +109,12 @@
109109
# The paper size ('letterpaper' or 'a4paper').
110110
#
111111
# 'papersize': 'letterpaper',
112-
113112
# The font size ('10pt', '11pt' or '12pt').
114113
#
115114
# 'pointsize': '10pt',
116-
117115
# Additional stuff for the LaTeX preamble.
118116
#
119117
# 'preamble': '',
120-
121118
# Latex figure (float) alignment
122119
#
123120
# 'figure_align': 'htbp',
@@ -127,8 +124,13 @@
127124
# (source start file, target name, title,
128125
# author, documentclass [howto, manual, or own class]).
129126
latex_documents = [
130-
(master_doc, 'KeybaseSSHCABot.tex', u'Keybase SSH CA Bot Documentation',
131-
u'keybase.io', 'manual'),
127+
(
128+
master_doc,
129+
"KeybaseSSHCABot.tex",
130+
u"Keybase SSH CA Bot Documentation",
131+
u"keybase.io",
132+
"manual",
133+
),
132134
]
133135

134136

@@ -137,8 +139,7 @@
137139
# One entry per manual page. List of tuples
138140
# (source start file, name, description, authors, manual section).
139141
man_pages = [
140-
(master_doc, 'keybasesshcabot', u'Keybase SSH CA Bot Documentation',
141-
[author], 1)
142+
(master_doc, "keybasesshcabot", u"Keybase SSH CA Bot Documentation", [author], 1,)
142143
]
143144

144145

@@ -148,9 +149,15 @@
148149
# (source start file, target name, title, author,
149150
# dir menu entry, description, category)
150151
texinfo_documents = [
151-
(master_doc, 'KeybaseSSHCABot', u'Keybase SSH CA Bot Documentation',
152-
author, 'KeybaseSSHCABot', 'One line description of project.',
153-
'Miscellaneous'),
152+
(
153+
master_doc,
154+
"KeybaseSSHCABot",
155+
u"Keybase SSH CA Bot Documentation",
156+
author,
157+
"KeybaseSSHCABot",
158+
"One line description of project.",
159+
"Miscellaneous",
160+
),
154161
]
155162

156163

@@ -169,6 +176,6 @@
169176
# epub_uid = ''
170177

171178
# A list of files that should not be packed into the epub file.
172-
epub_exclude_files = ['search.html']
179+
epub_exclude_files = ["search.html"]
173180

174181
collapse_navigation = False

0 commit comments

Comments
 (0)