mirror of
				https://gitea.publichub.eu/oscar.krause/fastapi-dls.git
				synced 2025-11-04 04:56:07 +00:00 
			
		
		
		
	hardcoded default CORS to https, since drivers only support secure connections
This commit is contained in:
		@@ -287,12 +287,14 @@ After first success you have to replace `--issue` with `--renew`.
 | 
				
			|||||||
| `DLS_PORT`          | `443`                                  | Used in client-token to tell guest driver where dls instance is reachable           |
 | 
					| `DLS_PORT`          | `443`                                  | Used in client-token to tell guest driver where dls instance is reachable           |
 | 
				
			||||||
| `LEASE_EXPIRE_DAYS` | `90`                                   | Lease time in days                                                                  |
 | 
					| `LEASE_EXPIRE_DAYS` | `90`                                   | Lease time in days                                                                  |
 | 
				
			||||||
| `DATABASE`          | `sqlite:///db.sqlite`                  | See [official SQLAlchemy docs](https://docs.sqlalchemy.org/en/14/core/engines.html) |
 | 
					| `DATABASE`          | `sqlite:///db.sqlite`                  | See [official SQLAlchemy docs](https://docs.sqlalchemy.org/en/14/core/engines.html) |
 | 
				
			||||||
| `CORS_ORIGINS`      | `https://{DLS_URL}`                    | Sets `Access-Control-Allow-Origin` header (comma separated string)                  |
 | 
					| `CORS_ORIGINS`      | `https://{DLS_URL}`                    | Sets `Access-Control-Allow-Origin` header (comma separated string) \*               |
 | 
				
			||||||
| `SITE_KEY_XID`      | `00000000-0000-0000-0000-000000000000` | Site identification uuid                                                            |
 | 
					| `SITE_KEY_XID`      | `00000000-0000-0000-0000-000000000000` | Site identification uuid                                                            |
 | 
				
			||||||
| `INSTANCE_REF`      | `00000000-0000-0000-0000-000000000000` | Instance identification uuid                                                        |
 | 
					| `INSTANCE_REF`      | `00000000-0000-0000-0000-000000000000` | Instance identification uuid                                                        |
 | 
				
			||||||
| `INSTANCE_KEY_RSA`  | `<app-dir>/cert/instance.private.pem`  | Site-wide private RSA key for singing JWTs                                          |
 | 
					| `INSTANCE_KEY_RSA`  | `<app-dir>/cert/instance.private.pem`  | Site-wide private RSA key for singing JWTs                                          |
 | 
				
			||||||
| `INSTANCE_KEY_PUB`  | `<app-dir>/cert/instance.public.pem`   | Site-wide public key                                                                |
 | 
					| `INSTANCE_KEY_PUB`  | `<app-dir>/cert/instance.public.pem`   | Site-wide public key                                                                |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\* Always use `https`, since guest-drivers only support secure connections!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Setup (Client)
 | 
					# Setup (Client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**The token file has to be copied! It's not enough to C&P file contents, because there can be special characters.**
 | 
					**The token file has to be copied! It's not enough to C&P file contents, because there can be special characters.**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,8 +40,7 @@ INSTANCE_KEY_RSA = load_key(str(env('INSTANCE_KEY_RSA', join(dirname(__file__),
 | 
				
			|||||||
INSTANCE_KEY_PUB = load_key(str(env('INSTANCE_KEY_PUB', join(dirname(__file__), 'cert/instance.public.pem'))))
 | 
					INSTANCE_KEY_PUB = load_key(str(env('INSTANCE_KEY_PUB', join(dirname(__file__), 'cert/instance.public.pem'))))
 | 
				
			||||||
TOKEN_EXPIRE_DELTA = relativedelta(hours=1)  # days=1
 | 
					TOKEN_EXPIRE_DELTA = relativedelta(hours=1)  # days=1
 | 
				
			||||||
LEASE_EXPIRE_DELTA = relativedelta(days=int(env('LEASE_EXPIRE_DAYS', 90)))
 | 
					LEASE_EXPIRE_DELTA = relativedelta(days=int(env('LEASE_EXPIRE_DAYS', 90)))
 | 
				
			||||||
 | 
					CORS_ORIGINS = env('CORS_ORIGINS').split(',') if (env('CORS_ORIGINS')) else f'https://{DLS_URL}'
 | 
				
			||||||
CORS_ORIGINS = env('CORS_ORIGINS').split(',') if (env('CORS_ORIGINS')) else f'https://{DLS_URL}'  # todo: prevent static https
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
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)
 | 
				
			||||||
jwt_decode_key = jwk.construct(INSTANCE_KEY_PUB.export_key().decode('utf-8'), algorithm=ALGORITHMS.RS256)
 | 
					jwt_decode_key = jwk.construct(INSTANCE_KEY_PUB.export_key().decode('utf-8'), algorithm=ALGORITHMS.RS256)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user