Compare commits
No commits in common. "95427d430ef7e911f34e56f3728f50436b17a448" and "38177fa2594e273d748d2cf3c6aa45a27cc4e23e" have entirely different histories.
95427d430e
...
38177fa259
@ -7,14 +7,6 @@ Compatibility tested with official DLS 2.0.1.
|
|||||||
This service can be used without internet connection.
|
This service can be used without internet connection.
|
||||||
Only the clients need a connection to this service on configured port.
|
Only the clients need a connection to this service on configured port.
|
||||||
|
|
||||||
**Official Links**
|
|
||||||
|
|
||||||
- https://git.collinwebdesigns.de/oscar.krause/fastapi-dls
|
|
||||||
- https://gitea.publichub.eu/oscar.krause/fastapi-dls
|
|
||||||
- Docker Image `collinwebdesigns/fastapi-dls:latest`
|
|
||||||
|
|
||||||
*All other repositories are forks!*
|
|
||||||
|
|
||||||
[[_TOC_]]
|
[[_TOC_]]
|
||||||
|
|
||||||
# Setup (Service)
|
# Setup (Service)
|
||||||
|
12
app/main.py
12
app/main.py
@ -45,7 +45,6 @@ TOKEN_EXPIRE_DELTA = relativedelta(days=int(env('TOKEN_EXPIRE_DAYS', 1)), hours=
|
|||||||
LEASE_EXPIRE_DELTA = relativedelta(days=int(env('LEASE_EXPIRE_DAYS', 90)), hours=int(env('LEASE_EXPIRE_HOURS', 0)))
|
LEASE_EXPIRE_DELTA = relativedelta(days=int(env('LEASE_EXPIRE_DAYS', 90)), hours=int(env('LEASE_EXPIRE_HOURS', 0)))
|
||||||
LEASE_RENEWAL_PERIOD = float(env('LEASE_RENEWAL_PERIOD', 0.15))
|
LEASE_RENEWAL_PERIOD = float(env('LEASE_RENEWAL_PERIOD', 0.15))
|
||||||
LEASE_RENEWAL_DELTA = timedelta(days=int(env('LEASE_EXPIRE_DAYS', 90)), hours=int(env('LEASE_EXPIRE_HOURS', 0)))
|
LEASE_RENEWAL_DELTA = timedelta(days=int(env('LEASE_EXPIRE_DAYS', 90)), hours=int(env('LEASE_EXPIRE_HOURS', 0)))
|
||||||
CLIENT_TOKEN_EXPIRE_DELTA = relativedelta(years=12)
|
|
||||||
CORS_ORIGINS = str(env('CORS_ORIGINS', '')).split(',') if (env('CORS_ORIGINS')) else [f'https://{DLS_URL}']
|
CORS_ORIGINS = str(env('CORS_ORIGINS', '')).split(',') if (env('CORS_ORIGINS')) else [f'https://{DLS_URL}']
|
||||||
|
|
||||||
jwt_encode_key = jwk.construct(INSTANCE_KEY_RSA.export_key().decode('utf-8'), algorithm=ALGORITHMS.RS256)
|
jwt_encode_key = jwk.construct(INSTANCE_KEY_RSA.export_key().decode('utf-8'), algorithm=ALGORITHMS.RS256)
|
||||||
@ -197,7 +196,7 @@ async def _lease_delete(request: Request, lease_ref: str):
|
|||||||
@app.get('/-/client-token', summary='* Client-Token', description='creates a new messenger token for this service instance')
|
@app.get('/-/client-token', summary='* Client-Token', description='creates a new messenger token for this service instance')
|
||||||
async def _client_token():
|
async def _client_token():
|
||||||
cur_time = datetime.utcnow()
|
cur_time = datetime.utcnow()
|
||||||
exp_time = cur_time + CLIENT_TOKEN_EXPIRE_DELTA
|
exp_time = cur_time + relativedelta(years=12)
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"jti": str(uuid4()),
|
"jti": str(uuid4()),
|
||||||
@ -536,14 +535,7 @@ async def leasing_v1_lessor_shutdown(request: Request):
|
|||||||
|
|
||||||
@app.on_event('startup')
|
@app.on_event('startup')
|
||||||
async def app_on_startup():
|
async def app_on_startup():
|
||||||
logger.info(f'''
|
logger.info(f'Using timezone: {str(TZ)}. Make sure this is correct and match your clients!')
|
||||||
Using timezone: {str(TZ)}. Make sure this is correct and match your clients!
|
|
||||||
|
|
||||||
Your clients renew their license every {str(Lease.calculate_renewal(LEASE_RENEWAL_PERIOD, LEASE_RENEWAL_DELTA))}.
|
|
||||||
If the renewal fails, the license is {str(LEASE_RENEWAL_DELTA)} valid.
|
|
||||||
|
|
||||||
Your client-token file (.tok) is valid for {str(CLIENT_TOKEN_EXPIRE_DELTA)}.
|
|
||||||
''')
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -170,14 +170,6 @@ class Lease(Base):
|
|||||||
renew = delta.total_seconds() * LEASE_RENEWAL_PERIOD
|
renew = delta.total_seconds() * LEASE_RENEWAL_PERIOD
|
||||||
renew = datetime.timedelta(seconds=renew)
|
renew = datetime.timedelta(seconds=renew)
|
||||||
expires = delta - renew # 19.2
|
expires = delta - renew # 19.2
|
||||||
|
|
||||||
import datetime
|
|
||||||
LEASE_RENEWAL_PERIOD=0.15 # 15%
|
|
||||||
delta = datetime.timedelta(days=90)
|
|
||||||
renew = delta.total_seconds() * LEASE_RENEWAL_PERIOD
|
|
||||||
renew = datetime.timedelta(seconds=renew)
|
|
||||||
expires = delta - renew # 76 days, 12:00:00 hours
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
renew = delta.total_seconds() * renewal_period
|
renew = delta.total_seconds() * renewal_period
|
||||||
renew = timedelta(seconds=renew)
|
renew = timedelta(seconds=renew)
|
||||||
|
Loading…
Reference in New Issue
Block a user