kodeco 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/periscope/cli.rb +19 -3
- data/lib/periscope/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 92f1b3f3a2c07ef7de80d5e2bcf2e7dd6989cd5baa29c56d085ea8fe61294e66
|
|
4
|
+
data.tar.gz: 75794675c957b94474ece30dfaebb15c2c28f3b0798208b48242aa7989fb1e94
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95eac6af137ca2809784e1adc765a4143a54bf7f0891236f105810645b5296de87c08367012c72a304361dd96a82940aa31efe85bb2036eaf58a029f7bcf1a6b
|
|
7
|
+
data.tar.gz: 846d4357394ca12d042e4cf57476975866289452a0f3b74f764d0300e5503a0657e5efd45646ed155a531a4e1db39ddce6d39ebebfae2ed2650e078922232212
|
data/README.md
CHANGED
|
@@ -34,8 +34,10 @@ for lists.
|
|
|
34
34
|
`login` uses guardpost's device-code flow: it prints a code and a link to
|
|
35
35
|
approve it, and opens the link in a browser when run in a terminal. The
|
|
36
36
|
default scopes are `users:read support:read orders:read learning:read
|
|
37
|
-
flags:read`.
|
|
38
|
-
|
|
37
|
+
flags:read`. Scopes other than `flags:read` need a grant from a guardpost
|
|
38
|
+
admin. A login gets whichever of the requested scopes you hold, and `login`
|
|
39
|
+
lists any that weren't granted; a grant added later needs a fresh
|
|
40
|
+
`kodeco login`.
|
|
39
41
|
|
|
40
42
|
`logout` deletes the local credentials. guardpost has no revoke endpoint, so
|
|
41
43
|
the server session lasts up to 7 days unless an admin revokes it.
|
data/lib/periscope/cli.rb
CHANGED
|
@@ -68,9 +68,25 @@ module Periscope
|
|
|
68
68
|
opener = method(:open_browser) if @stdout.tty? && opts.fetch(:browser, true)
|
|
69
69
|
login = Login.new(config: config, store: store, http: http, out: @json ? @stderr : @stdout,
|
|
70
70
|
opener: opener, **@login_options)
|
|
71
|
-
|
|
72
|
-
result =
|
|
73
|
-
emit(result) { "
|
|
71
|
+
requested = (opts[:scopes] || Login::DEFAULT_SCOPES).split
|
|
72
|
+
result = login_result(requested, login.call(requested.join(" ")))
|
|
73
|
+
emit(result) { login_text(result["granted"], result["missing"]) }
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# guardpost approves a login with only the scopes the user holds, so
|
|
77
|
+
# compare what was asked for with what came back.
|
|
78
|
+
def login_result(requested, credentials)
|
|
79
|
+
granted = credentials["scope"].to_s.split
|
|
80
|
+
{ "logged_in" => true, "requested" => requested, "granted" => granted, "missing" => requested - granted,
|
|
81
|
+
"scope" => credentials["scope"], "apps" => credentials["access_tokens"].keys }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def login_text(granted, missing)
|
|
85
|
+
text = "Logged in with: #{granted.empty? ? '(no scopes)' : granted.join(', ')}"
|
|
86
|
+
return text if missing.empty?
|
|
87
|
+
|
|
88
|
+
"#{text}\nNot granted: #{missing.join(', ')}. Ask an admin to add them on your guardpost user page, " \
|
|
89
|
+
"then run kodeco login again."
|
|
74
90
|
end
|
|
75
91
|
|
|
76
92
|
def cmd_logout
|
data/lib/periscope/version.rb
CHANGED