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
c02eee85
Unverified
Commit
c02eee85
authored
7 years ago
by
Sameer Al-Sakran
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #6942 from metabase/return-400-for-bad-metastore-token
Setting bad MetaStore token should return 400, not 500
parents
e6bef552
ecd443f7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/admin/settings/components/widgets/EmbeddingLevel.jsx
+39
-14
39 additions, 14 deletions
...base/admin/settings/components/widgets/EmbeddingLevel.jsx
src/metabase/public_settings/metastore.clj
+11
-7
11 additions, 7 deletions
src/metabase/public_settings/metastore.clj
with
50 additions
and
21 deletions
frontend/src/metabase/admin/settings/components/widgets/EmbeddingLevel.jsx
+
39
−
14
View file @
c02eee85
...
...
@@ -2,25 +2,50 @@ import React, { Component } from "react";
import
ReactRetinaImage
from
"
react-retina-image
"
;
import
{
t
}
from
"
c-3po
"
;
import
SettingsInput
from
"
./SettingInput
"
;
import
cx
from
"
classnames
"
;
const
PREMIUM_EMBEDDING_STORE_URL
=
"
https://store.metabase.com/product/embedding
"
;
const
PREMIUM_EMBEDDING_SETTING_KEY
=
"
premium-embedding-token
"
;
const
PremiumTokenInput
=
({
token
,
onChangeSetting
})
=>
(
<
div
className
=
"mb3"
>
<
h3
className
=
"mb1"
>
{
token
?
t
`Premium embedding enabled`
:
t
`Enter the token you bought from the Metabase Store`
}
</
h3
>
<
SettingsInput
onChange
=
{
value
=>
onChangeSetting
(
PREMIUM_EMBEDDING_SETTING_KEY
,
value
)
}
setting
=
{
{
value
:
token
}
}
autoFocus
=
{
!
token
}
/>
</
div
>
);
class
PremiumTokenInput
extends
Component
{
state
=
{
errorMessage
:
""
,
};
render
()
{
const
{
token
,
onChangeSetting
}
=
this
.
props
;
const
{
errorMessage
}
=
this
.
state
;
let
message
;
if
(
errorMessage
)
{
message
=
errorMessage
;
}
else
if
(
token
)
{
message
=
t
`Premium embedding enabled`
;
}
else
{
message
=
t
`Enter the token you bought from the Metabase Store`
;
}
return
(
<
div
className
=
"mb3"
>
<
h3
className
=
{
cx
(
"
mb1
"
,
{
"
text-danger
"
:
errorMessage
})
}
>
{
message
}
</
h3
>
<
SettingsInput
onChange
=
{
async
value
=>
{
try
{
await
onChangeSetting
(
PREMIUM_EMBEDDING_SETTING_KEY
,
value
);
}
catch
(
error
)
{
this
.
setState
({
errorMessage
:
error
.
data
});
}
}
}
setting
=
{
{
value
:
token
}
}
autoFocus
=
{
!
token
}
/>
</
div
>
);
}
}
const
PremiumExplanation
=
({
showEnterScreen
})
=>
(
<
div
>
...
...
This diff is collapsed.
Click to expand it.
src/metabase/public_settings/metastore.clj
+
11
−
7
View file @
c02eee85
...
...
@@ -47,15 +47,15 @@
;; slurp will throw a FileNotFoundException for 404s, so in that case just return an appropriate
;; 'Not Found' message
(
catch
java.io.FileNotFoundException
e
{
:valid
false,
:status
"
invalid token: not found
."
})
{
:valid
false,
:status
"
Unable to validate token
."
})
;; if there was any other error fetching the token, log it and return a generic message about the
;; token being invalid. This message will get displayed in the Settings page in the admin panel so
;; we do not want something complicated
(
catch
Throwable
e
(
log/error
"Error fetching token status:"
e
)
{
:valid
false,
:status
"
t
here was an error checking whether this token was valid."
})))
{
:valid
false,
:status
"
T
here was an error checking whether this token was valid."
})))
fetch-token-status-timeout-ms
{
:valid
false,
:status
"
t
oken validation timed out."
})))
{
:valid
false,
:status
"
T
oken validation timed out."
})))
(
defn-
check-embedding-token-is-valid*
[
token
]
(
when
(
s/check
ValidToken
token
)
...
...
@@ -86,10 +86,14 @@
"Token for premium embedding. Go to the MetaStore to get yours!"
:setter
(
fn
[
new-value
]
;; validate the new value if we're not unsetting it
(
when
(
seq
new-value
)
(
check-embedding-token-is-valid
new-value
)
(
log/info
"Token is valid."
))
(
setting/set-string!
:premium-embedding-token
new-value
)))
(
try
(
when
(
seq
new-value
)
(
check-embedding-token-is-valid
new-value
)
(
log/info
"Token is valid."
))
(
setting/set-string!
:premium-embedding-token
new-value
)
(
catch
Throwable
e
(
log/error
e
"Error setting premium embedding token"
)
(
throw
(
ex-info
(
.getMessage
e
)
{
:status-code
400
}))))))
(
defn
hide-embed-branding?
"Should we hide the 'Powered by Metabase' attribution on the embedding pages? `true` if we have a valid premium
...
...
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