Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
d4b264df
Unverified
Commit
d4b264df
authored
6 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Simplified way to keep setup token in sync.
parent
008c5faf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/setup.clj
+17
-11
17 additions, 11 deletions
src/metabase/setup.clj
with
17 additions
and
11 deletions
src/metabase/setup.clj
+
17
−
11
View file @
d4b264df
(
ns
metabase.setup
)
(
ns
metabase.setup
(
:require
[
metabase.models.setting
:refer
[
Setting
defsetting
]]
[
toucan.db
:as
db
]))
(
defonce
^
:private
setup-token
(
atom
nil
))
(
defsetting
^
:private
setup-token
"A token used to signify that an instance has permissions to create the initial User. This is created upon the first
launch of Metabase, by the first instance; once used, it is cleared out, never to be used again."
:internal?
true
)
(
defn
token-value
"Return the value of the setup token, if any."
[]
@
setup-token
)
(
setup-token
)
)
(
defn
token-match?
"Function for checking if the supplied string matches our setup token.
Returns boolean `true` if supplied token matches
`@
setup
-
token
`
, `false` otherwise."
Returns boolean `true` if supplied token matches
the
setup
token, `false` otherwise."
[
token
]
{
:pre
[(
string?
token
)]}
(
=
token
@
setup-token
))
(
=
token
(
setup-token
))
)
(
defn
create-token!
"Create and set a new `@setup-token`.
Returns the newly created token."
"Create and set a new setup token, if one has not already been created. Returns the newly created token."
[]
(
reset!
setup-token
(
str
(
java.util.UUID/randomUUID
))))
;; fetch the value directly from the DB; *do not* rely on cached value, in case a different instance came along and
;; already created it
(
or
(
db/select-one-field
:value
Setting
:key
"setup-token"
)
(
setup-token
(
str
(
java.util.UUID/randomUUID
)))))
(
defn
clear-token!
"Clear the
`@
setup
-
token
`
if it exists and reset it to nil."
"Clear the setup
token if it exists and reset it to
`
nil
`
."
[]
(
reset!
setup-token
nil
))
(
setup-token
nil
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment