Skip to content
Snippets Groups Projects
Verified Commit b9f62834 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'dev' into f-filesystem

parents 39ffe48a e7b7de3f
No related branches found
No related tags found
2 merge requests!86Draft: ENH: file system: core,!58F filesystem
This commit is part of merge request !86. Comments created here will be created in the context of that merge request.
......@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ##
### Added ###
- function in administration that generates passwords that comply with the
rules
### Changed ###
### Deprecated ###
### Removed ###
### Fixed ###
### Security ###
## [0.6.1] - 2021-12-03 ##
### Fixed ###
......
......@@ -39,4 +39,4 @@ guidelines of the CaosDB Project
11. After the merge of main to dev, start a new development version by
setting `ISRELEASED` to `False` and by increasing at least the `MIRCO`
version in [setup.py](./setup.py)
version in [setup.py](./setup.py) and preparing CHANGELOG.md.
......@@ -47,9 +47,9 @@ from setuptools import find_packages, setup
MAJOR = 0
MINOR = 6
MICRO = 1
MICRO = 2
PRE = "" # e.g. rc0, alpha.1, 0.beta-23
ISRELEASED = True
ISRELEASED = False
if PRE:
VERSION = "{}.{}.{}-{}".format(MAJOR, MINOR, MICRO, PRE)
......
......@@ -26,6 +26,9 @@
"""missing docstring."""
import re
import string
import random
from caosdb.common.utils import xml2str
from caosdb.connection.connection import get_connection
from caosdb.exceptions import (EntityDoesNotExistError, HTTPClientError,
......@@ -56,7 +59,8 @@ def set_server_property(key, value):
con._form_data_request(method="POST", path="_server_properties",
params={key: value}).read()
except EntityDoesNotExistError:
raise ServerConfigurationException("Debug mode in server is probably disabled.") from None
raise ServerConfigurationException(
"Debug mode in server is probably disabled.") from None
def get_server_properties():
......@@ -71,9 +75,11 @@ def get_server_properties():
"""
con = get_connection()
try:
body = con._http_request(method="GET", path="_server_properties").response
body = con._http_request(
method="GET", path="_server_properties").response
except EntityDoesNotExistError:
raise ServerConfigurationException("Debug mode in server is probably disabled.") from None
raise ServerConfigurationException(
"Debug mode in server is probably disabled.") from None
xml = etree.parse(body)
props = dict()
......@@ -108,6 +114,39 @@ def get_server_property(key):
return get_server_properties()[key]
def generate_password(length: int):
"""Create a random password that fulfills the security requirements
Parameters
----------
length : int
Length of the generated password. Has to be greater than 7.
Returns
-------
password : string
Generated random password of the given length
Raises
------
ValueError:
If the length is less than 8.
"""
minimum_password_length = 8
if length < minimum_password_length:
raise ValueError("CaosDB passwords have to be at least {} characters.".format(
minimum_password_length))
sample_letters = string.ascii_letters + string.digits + "!#$%*+-/:;?_"
password = ''.join((random.choice(sample_letters) for i in range(length)))
while not re.match(r"(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_]).{8,}",
password):
password = ''.join((random.choice(sample_letters)
for i in range(length)))
return password
def _retrieve_user(name, realm=None, **kwargs):
con = get_connection()
try:
......
......@@ -17,7 +17,7 @@ schema-pycaosdb-ini:
description: URL of the CaosDB server
type: string
pattern: https://[-a-zA-Z0-9\.]+(:[0-9]+)?(/)?
examples: [https://demo.indiscale.com/, https://localhost:10443/]
examples: ["https://demo.indiscale.com/", "https://localhost:10443/"]
username:
type: string
description: User name used for authentication with the server
......@@ -52,7 +52,7 @@ schema-pycaosdb-ini:
enum: [0, 1, 2]
description: The debug key allows control the verbosity. Set it to 1 or 2 in case you want to see debugging output or if you want to learn more about the internals of the protocol. 0 disables debugging output.
socket_proxy:
examples: [localhost:12345]
examples: ["localhost:12345"]
type: string
description: You can define a socket proxy to be used. This is for the case that the server sits behind a firewall which is being tunnelled with a socket proxy (SOCKS4 or SOCKS5) (e.g. via ssh's -D option or a dedicated proxy server).
implementation:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment