Skip to content

Commit

Permalink
Merge branch 'master' into bleepbop/VIRTS-4705/discarded-abilities-in…
Browse files Browse the repository at this point in the history
…-steps
  • Loading branch information
elegantmoose authored Sep 28, 2023
2 parents 78c3dc7 + 60ed4ab commit 8322359
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
18 changes: 9 additions & 9 deletions app/service/auth_svc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import base64
from collections import namedtuple
from hmac import compare_digest
from importlib import import_module

from aiohttp import web, web_request
Expand Down Expand Up @@ -138,14 +139,13 @@ async def login_redirect(self, request, use_template=True):
raise e

def request_has_valid_api_key(self, request):
api_key = request.headers.get(HEADER_API_KEY)

if api_key is None:
request_api_key = request.headers.get(HEADER_API_KEY)
if request_api_key is None:
return False
if api_key == self.get_config(CONFIG_API_KEY_RED):
return True
if api_key == self.get_config(CONFIG_API_KEY_BLUE):
return True
for i in [CONFIG_API_KEY_RED, CONFIG_API_KEY_BLUE]:
api_key = self.get_config(i)
if api_key is not None and compare_digest(request_api_key, api_key):
return True
return False

async def request_has_valid_user_session(self, request):
Expand All @@ -170,9 +170,9 @@ async def get_permissions(self, request):
identity = await identity_policy.identify(request)
if identity in self.user_map:
return [self.Access[p.upper()] for p in self.user_map[identity].permissions]
elif request.headers.get('KEY') == self.get_config('api_key_red'):
elif request.headers.get(HEADER_API_KEY) == self.get_config(CONFIG_API_KEY_RED):
return self.Access.RED, self.Access.APP
elif request.headers.get('KEY') == self.get_config('api_key_blue'):
elif request.headers.get(HEADER_API_KEY) == self.get_config(CONFIG_API_KEY_BLUE):
return self.Access.BLUE, self.Access.APP
return ()

Expand Down
28 changes: 19 additions & 9 deletions templates/sources.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ <h2>Fact Sources</h2>
</div>
</template>
<template x-for="(fact, index) in filteredFacts" :key="fact.trait">
<div class="box sources mb-2 mr-2 p-3 is-flex is-justify-content-center is-align-items-center is-flex-direction-column"
@click="($event) => editCard = ($event.target.id !== 'cancel-edit-fact') ? fact.trait : null"
<div class="box sources mb-2 mr-2 p-3 is-flex is-justify-content-center is-align-items-center is-flex-direction-column">
<div class="w-100" @click="($event) => editCard = ($event.target.id !== 'cancel-edit-fact') ? fact.trait : null"
x-data="{editedValues: {}, editedScores: {}, newTags: [], editedNames: {}}">
<div>
<p x-show="editCard !== fact.trait" x-bind:class="{'has-background-warning has-text-black': editCard === fact.trait}" class="p-1" x-text="fact.trait"></p>
<p x-show="editCard !== fact.trait" x-bind:class="{'has-background-warning has-text-black': editCard === fact.trait}" class="p-1 has-text-centered" x-text="fact.trait"></p>
<input class="input is-small" x-show="editCard === fact.trait" x-model="editedNames[fact.trait]" x-init="editedNames[fact.trait] = fact.trait">
<template x-if="editCard === fact.trait">
<button class="button is-danger is-outlined is-small delete-card-button" @click="deleteFact(fact.trait)"><span class="icon"><em class="fas fa-trash"></em></span></button>
Expand All @@ -179,22 +179,22 @@ <h2>Fact Sources</h2>
x-init="$watch('filteredFacts', updated => {if (updated && updated[index]) fact.scores = updated[index].scores;})">
<div>
<div class="is-flex is-justify-content-center is-align-items-center is-flex-direction-row is-flex-wrap-wrap">
<span x-show-="editCard !== fact.trait"
<span x-show="editCard !== fact.trait"
class="tag break-spaces is-info"
x-text="score.score + (score.score > 1 ? ' pts:' :' pt:')"></span>
<template x-for="(val, index) in score.values" :key="val+index">
<template x-for="(val, index) in score.values" :key="val.id">
<div>
<template x-if="editCard !== fact.trait">
<span class="tag is-light break-spaces editable-tag"
x-text="(val ? val : '--')"></span>
x-text="(val.value ? val.value : '--')"></span>
</template>
<template x-if="editCard === fact.trait">
<div>
<div class="tags has-addons mb-0">
<span class="is-italic tag is-light break-spaces">
<input type="text" class="tag-input"
x-bind:value="val"
x-on:change="val = editedValues[score.unique] = $event.target.value;">
x-bind:value="val.value"
x-on:change="val.value = editedValues[score.unique] = $event.target.value;">
</span>
<span class="tag is-white break-spaces">
<input class="tag-number-input"
Expand All @@ -203,7 +203,7 @@ <h2>Fact Sources</h2>
pattern="[0-9]*"
placeholder="1"
x-bind:value="score.score">
<button @click="score.values.splice(index, 1) && deleteFactValue(fact.trait, score.unique, val)"
<button @click="score.values.splice(index, 1) && deleteFactValue(fact.trait, score.unique, val.value)"
class="delete is-small"></button>
</span>
</div>
Expand Down Expand Up @@ -259,6 +259,7 @@ <h2>Fact Sources</h2>
</div>
</div>
</div>
</div>
</template>
</div>
</template>
Expand Down Expand Up @@ -959,6 +960,15 @@ <h2>Fact Sources</h2>
this.filteredFacts = Object.keys(facts).map(key => {
const fact = facts[key];
fact.scores = Object.keys(fact.scores).map(s => facts[key].scores[s]);
// Give each fact score value a unique id for easy deletion
fact.scores.forEach((score) => {
score.values.forEach((value, index) => {
score.values[index] = {
id: `${fact.trait}-${score.score}-${index}`,
value: value
};
});
});
return fact;
});
this.filteredRules = Object.keys(rules).map(key => rules[key]);
Expand Down

0 comments on commit 8322359

Please sign in to comment.