allow users with admin:metrics to read app metrics
ci/woodpecker/push/woodpecker Pipeline is pending
Details
ci/woodpecker/push/woodpecker Pipeline is pending
Details
parent
b8be8192fb
commit
c2054f82ab
@ -1,2 +1,8 @@
|
||||
<h1><%= Gettext.dpgettext("static_pages", "oauth authorized page title", "Successfully authorized") %></h1>
|
||||
<h2><%= raw Gettext.dpgettext("static_pages", "oauth token code message", "Token code is <br>%{token}", token: safe_to_string(html_escape(@auth.token))) %></h2>
|
||||
<div>
|
||||
<div class="panel-heading">
|
||||
<%= Gettext.dpgettext("static_pages", "oauth authorized page title", "Successfully authorized") %>
|
||||
</div>
|
||||
<div class="panel-content">
|
||||
<%= raw Gettext.dpgettext("static_pages", "oauth token code message", "Token code is <br>%{token}", token: safe_to_string(html_escape(@auth.token))) %>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -0,0 +1,114 @@
|
||||
form {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input {
|
||||
color: var(--muted-text-color);
|
||||
display: flex;
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
input {
|
||||
padding: 10px;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 10px;
|
||||
background-color: var(--background-color);
|
||||
color: var(--primary-text-color);
|
||||
border: 0;
|
||||
transition-property: border-bottom;
|
||||
transition-duration: 0.35s;
|
||||
border-bottom: 2px solid #2a384a;
|
||||
font-size: 14px;
|
||||
width: inherit;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.scopes-input {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 1em 0;
|
||||
color: var(--muted-text-color);
|
||||
}
|
||||
|
||||
.scopes-input label:first-child {
|
||||
height: 2em;
|
||||
}
|
||||
|
||||
.scopes {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
|
||||
.scope {
|
||||
display: flex;
|
||||
flex-basis: 100%;
|
||||
height: 2em;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.scope:before {
|
||||
color: var(--primary-text-color);
|
||||
content: "✔\fe0e";
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
[type="checkbox"]+label {
|
||||
display: none;
|
||||
cursor: pointer;
|
||||
margin: 0.5em;
|
||||
}
|
||||
|
||||
[type="checkbox"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
[type="checkbox"]+label:before {
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
color: white;
|
||||
background-color: var(--background-color);
|
||||
border: 4px solid var(--background-color);
|
||||
box-shadow: 0px 0px 1px 0 var(--brand-color);
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
margin-right: 1.0em;
|
||||
content: "";
|
||||
transition-property: background-color;
|
||||
transition-duration: 0.35s;
|
||||
color: var(--background-color);
|
||||
margin-bottom: -0.2em;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
[type="checkbox"]:checked+label:before {
|
||||
background-color: var(--brand-color);
|
||||
}
|
||||
|
||||
a.button,
|
||||
button {
|
||||
width: 100%;
|
||||
background-color: #1c2a3a;
|
||||
color: var(--primary-text-color);
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
padding: 10px 16px;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
text-transform: uppercase;
|
||||
font-size: 16px;
|
||||
box-shadow: 0px 0px 2px 0px black,
|
||||
0px 1px 0px 0px rgba(255, 255, 255, 0.2) inset,
|
||||
0px -1px 0px 0px rgba(0, 0, 0, 0.2) inset;
|
||||
}
|
||||
|
||||
a.button:hover,
|
||||
button:hover {
|
||||
cursor: pointer;
|
||||
box-shadow: 0px 0px 0px 1px var(--brand-color),
|
||||
0px 1px 0px 0px rgba(255, 255, 255, 0.2) inset,
|
||||
0px -1px 0px 0px rgba(0, 0, 0, 0.2) inset;
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
|
||||
read -p "Instance URL (e.g https://example.com): " INSTANCE_URL
|
||||
|
||||
echo "Creating oauth app..."
|
||||
|
||||
RESP=$(curl \
|
||||
-XPOST \
|
||||
$INSTANCE_URL/api/v1/apps \
|
||||
--silent \
|
||||
--data-urlencode 'client_name=fedibash' \
|
||||
--data-urlencode 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' \
|
||||
--data-urlencode 'scopes=admin:metrics' \
|
||||
--header "Content-Type: application/x-www-form-urlencoded"
|
||||
)
|
||||
|
||||
client_id=$(echo $RESP | jq -r .client_id)
|
||||
client_secret=$(echo $RESP | jq -r .client_secret)
|
||||
|
||||
if [ -z "$client_id"]; then
|
||||
echo "Could not create an app"
|
||||
echo "$RESP"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Please visit the following URL and input the code provided"
|
||||
AUTH_URL="$INSTANCE_URL/oauth/authorize?client_id=$client_id&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=admin:metrics&response_type=code"
|
||||
if [ ! -z "$BROWSER" ]; then
|
||||
$BROWSER $AUTH_URL
|
||||
fi;
|
||||
|
||||
echo $AUTH_URL
|
||||
|
||||
read -p "Code: " CODE
|
||||
|
||||
echo "Requesting code..."
|
||||
|
||||
RESP=$(curl \
|
||||
-XPOST \
|
||||
$INSTANCE_URL/oauth/token \
|
||||
--silent \
|
||||
--header "Content-Type: application/x-www-form-urlencoded" \
|
||||
--data-urlencode "client_id=$client_id" \
|
||||
--data-urlencode "client_secret=$client_secret" \
|
||||
--data-urlencode "code=$CODE" \
|
||||
--data-urlencode "grant_type=authorization_code" \
|
||||
--data-urlencode 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' \
|
||||
--data-urlencode "scope=admin:metrics"
|
||||
)
|
||||
|
||||
ACCESS_TOKEN="$(echo $RESP | jq -r .access_token)"
|
||||
|
||||
echo "Token is $ACCESS_TOKEN"
|
||||
DOMAIN=$(echo $INSTANCE_URL | sed -e 's/^https:\/\///')
|
||||
|
||||
echo "Use the following config in your prometheus.yml:
|
||||
- job_name: akkoma
|
||||
scheme: https
|
||||
authorization:
|
||||
credentials: $ACCESS_TOKEN
|
||||
metrics_path: /api/v1/akkoma/metrics
|
||||
static_configs:
|
||||
- targets:
|
||||
- $DOMAIN
|
||||
"
|
Loading…
Reference in new issue