Skip to content

Commit

Permalink
Updated behavior to work around stash bug with API key used to access…
Browse files Browse the repository at this point in the history
… https
  • Loading branch information
devloch committed Jul 21, 2022
1 parent 303c852 commit 133caf1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ The folder /cache is used for an image cache, this can be stored in
| `-e API_KEY=xxxxxxxxx` | Specify the api key used to connect to stash if you have password protected your instance |
| `-e CACHE_DIR=/cache/` | The directory used to cache images, defaults to /cache/ in the docker container and ./cache/ if not specified |
| `-e DISABLE_CERT_VERIFICATION=True` | Disable certificate verification when connecting to stash, for cases where https is used |
| `-e DEOVR_USERNAME=user` | Username to require for authentication to the deovr endpoint |
| `-e DEOVR_PASSWORD=xxxx` | Password to require for authentication to the deovr endpoint |

```
docker stop stash-vr-companion
Expand Down
13 changes: 5 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@
app.config['GRAPHQL_API'] = os.getenv('API_URL', 'http://localhost:9999/graphql')
app.config['VERIFY_FLAG'] = not os.getenv('DISABLE_CERT_VERIFICATION', False)
# Disable insecure certificate verification warning when cert validation is disabled
if not app.config['VERIFY_FLAG']
if not app.config['VERIFY_FLAG']:
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)

if os.getenv('DEOVR_USERNAME') and os.getenv('DEOVR_PASSWORD')
app.config['BASIC_AUTH_USERNAME'] = os.getenv('DEOVR_USERNAME')
app.config['BASIC_AUTH_PASSWORD'] = os.getenv('DEOVR_PASSWORD')
# Setting this allows us to avoid flagging all endpoints as requiring the basic auth, so it can be conditional on
# whether the values are set.
app.config['BASIC_AUTH_FORCE'] = True

app.secret_key = 'N46XYWbnaXG6JtdJZxez'

Expand All @@ -39,6 +32,9 @@
}
if os.getenv('API_KEY'):
headers['ApiKey']=os.getenv('API_KEY')
# This header is not technically correct, but will work around a bug with stash https://github.com/stashapp/stash/issues/2764
if app.config['GRAPHQL_API'].lower().startswith("https"):
headers["X-Forwarded-Proto"] = "https"

studios=[]
performers=[]
Expand All @@ -59,6 +55,7 @@ def __callGraphQL(query, variables=None):
json['variables'] = variables

# handle cookies
print(app.config['VERIFY_FLAG'])
response = requests.post(app.config['GRAPHQL_API'], json=json, headers=headers, verify=app.config['VERIFY_FLAG'])

if response.status_code == 200:
Expand Down

0 comments on commit 133caf1

Please sign in to comment.