crud-mysql 0.1.6__tar.gz → 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/PKG-INFO +37 -1
- crud_mysql-0.1.7/README.md +70 -0
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/crud_mysql/endpoints.py +4 -0
- crud_mysql-0.1.7/crud_mysql/protect.py +19 -0
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/crud_mysql.egg-info/PKG-INFO +37 -1
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/crud_mysql.egg-info/SOURCES.txt +1 -0
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/crud_mysql.egg-info/requires.txt +3 -0
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/setup.py +2 -2
- crud_mysql-0.1.6/README.md +0 -37
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/LICENCE +0 -0
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/crud_mysql/__init__.py +0 -0
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/crud_mysql/crud_object.py +0 -0
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/crud_mysql/vars.py +0 -0
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/crud_mysql.egg-info/dependency_links.txt +0 -0
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/crud_mysql.egg-info/top_level.txt +0 -0
- {crud_mysql-0.1.6 → crud_mysql-0.1.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crud-mysql
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: crud defiend by json
|
|
5
5
|
Home-page: https://github.com/Ms-Shoshany/crud-mysql
|
|
6
6
|
Author: hanna
|
|
@@ -14,6 +14,9 @@ License-File: LICENCE
|
|
|
14
14
|
Requires-Dist: mysql-connector-python
|
|
15
15
|
Requires-Dist: mysql-database
|
|
16
16
|
Requires-Dist: flask
|
|
17
|
+
Requires-Dist: flask_jwt_extended
|
|
18
|
+
Requires-Dist: cryptography
|
|
19
|
+
Requires-Dist: PyJWT
|
|
17
20
|
Dynamic: author
|
|
18
21
|
Dynamic: author-email
|
|
19
22
|
Dynamic: classifier
|
|
@@ -62,3 +65,36 @@ cred.json - example
|
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
}
|
|
68
|
+
|
|
69
|
+
using tokens:
|
|
70
|
+
|
|
71
|
+
to protect endpoints by verifying tokens - add protected_methods to that object for example:
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
"car": {
|
|
75
|
+
"allowd_methods": ["GET", "POST", "DELETE", "PUT"],
|
|
76
|
+
"protected_methods": ["GET"],
|
|
77
|
+
"fetch_all": "true",
|
|
78
|
+
"schema": {
|
|
79
|
+
"owner": "VARCHAR(100)",
|
|
80
|
+
"color": "VARCHAR(100)",
|
|
81
|
+
"licence_plate": "INT"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
here when using "GET" to get a car we will need to add a token.
|
|
87
|
+
|
|
88
|
+
in order for this to work a few things need to be set:
|
|
89
|
+
an environment varriable JWT_ALGORITHM should be set.
|
|
90
|
+
the options are:
|
|
91
|
+
- RS256
|
|
92
|
+
- HS256
|
|
93
|
+
if none are set it will default to HS256.
|
|
94
|
+
|
|
95
|
+
if the algorithim being used is HS256 then a variable needs to be set for SECRET_KEY.
|
|
96
|
+
this has to be the same SECRET_KEY that was used for creating the jwt.
|
|
97
|
+
|
|
98
|
+
if the algorithim being used is RS256. a variable needs to be set for SECRET_KEYS_PATH.
|
|
99
|
+
and at that path there needs to be a public.pem
|
|
100
|
+
it has to be the same cert that was used to create the jwt.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
main.py / app.py - example
|
|
2
|
+
|
|
3
|
+
from flask import Flask
|
|
4
|
+
from flask_cors import CORS
|
|
5
|
+
from crud_mysql import crud
|
|
6
|
+
|
|
7
|
+
app = Flask(__name__)
|
|
8
|
+
|
|
9
|
+
app.register_blueprint(crud)
|
|
10
|
+
|
|
11
|
+
if __name__ == "__main__":
|
|
12
|
+
app.run(host="0.0.0.0", debug=True)
|
|
13
|
+
|
|
14
|
+
cred.json - example
|
|
15
|
+
|
|
16
|
+
{
|
|
17
|
+
"user": {
|
|
18
|
+
"allowd_methods": ["GET", "POST", "DELETE", "PUT"],
|
|
19
|
+
"fetch_all": "true",
|
|
20
|
+
"schema": {
|
|
21
|
+
"name": "VARCHAR(100)",
|
|
22
|
+
"email": "VARCHAR(100)",
|
|
23
|
+
"encrypted_password": "VARCHAR(100)",
|
|
24
|
+
"account_id": "INT",
|
|
25
|
+
"is_active": "INT"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"account": {
|
|
29
|
+
"allowd_methods": ["GET", "POST", "DELETE"],
|
|
30
|
+
"fetch_all": "false",
|
|
31
|
+
"schema": {
|
|
32
|
+
"name": "VARCHAR(100)",
|
|
33
|
+
"subscription_type": "VARCHAR(100)",
|
|
34
|
+
"root_user": "INT"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
using tokens:
|
|
40
|
+
|
|
41
|
+
to protect endpoints by verifying tokens - add protected_methods to that object for example:
|
|
42
|
+
|
|
43
|
+
{
|
|
44
|
+
"car": {
|
|
45
|
+
"allowd_methods": ["GET", "POST", "DELETE", "PUT"],
|
|
46
|
+
"protected_methods": ["GET"],
|
|
47
|
+
"fetch_all": "true",
|
|
48
|
+
"schema": {
|
|
49
|
+
"owner": "VARCHAR(100)",
|
|
50
|
+
"color": "VARCHAR(100)",
|
|
51
|
+
"licence_plate": "INT"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
here when using "GET" to get a car we will need to add a token.
|
|
57
|
+
|
|
58
|
+
in order for this to work a few things need to be set:
|
|
59
|
+
an environment varriable JWT_ALGORITHM should be set.
|
|
60
|
+
the options are:
|
|
61
|
+
- RS256
|
|
62
|
+
- HS256
|
|
63
|
+
if none are set it will default to HS256.
|
|
64
|
+
|
|
65
|
+
if the algorithim being used is HS256 then a variable needs to be set for SECRET_KEY.
|
|
66
|
+
this has to be the same SECRET_KEY that was used for creating the jwt.
|
|
67
|
+
|
|
68
|
+
if the algorithim being used is RS256. a variable needs to be set for SECRET_KEYS_PATH.
|
|
69
|
+
and at that path there needs to be a public.pem
|
|
70
|
+
it has to be the same cert that was used to create the jwt.
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
from flask import Blueprint
|
|
2
2
|
from flask import request, jsonify
|
|
3
3
|
from .crud_object import CrudObject
|
|
4
|
+
from .protect import protect
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
crud = Blueprint('crud', __name__, template_folder='templates')
|
|
6
8
|
|
|
9
|
+
|
|
7
10
|
@crud.route("/<object_type>", methods=["GET"])
|
|
11
|
+
@protect()
|
|
8
12
|
def get_object(object_type):
|
|
9
13
|
try:
|
|
10
14
|
crud_object = CrudObject(object_type)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from flask_jwt_extended import JWTManager, jwt_required, get_jwt
|
|
2
|
+
from flask import request
|
|
3
|
+
from functools import wraps
|
|
4
|
+
from crud_mysql.crud_object import CrudObject
|
|
5
|
+
|
|
6
|
+
def protect():
|
|
7
|
+
def decorator(fn):
|
|
8
|
+
@wraps(fn)
|
|
9
|
+
def wrapper(*args, **kwargs):
|
|
10
|
+
method = request.method
|
|
11
|
+
object_type = request.base_url.split("/")[-1]
|
|
12
|
+
crud = CrudObject(object_type).get_crud()[object_type]
|
|
13
|
+
if "protected_methods" in crud and method in crud["protected_methods"]:
|
|
14
|
+
return jwt_required()(fn)(*args, **kwargs)
|
|
15
|
+
else:
|
|
16
|
+
return fn(*args, **kwargs)
|
|
17
|
+
return wrapper
|
|
18
|
+
return decorator
|
|
19
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crud-mysql
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: crud defiend by json
|
|
5
5
|
Home-page: https://github.com/Ms-Shoshany/crud-mysql
|
|
6
6
|
Author: hanna
|
|
@@ -14,6 +14,9 @@ License-File: LICENCE
|
|
|
14
14
|
Requires-Dist: mysql-connector-python
|
|
15
15
|
Requires-Dist: mysql-database
|
|
16
16
|
Requires-Dist: flask
|
|
17
|
+
Requires-Dist: flask_jwt_extended
|
|
18
|
+
Requires-Dist: cryptography
|
|
19
|
+
Requires-Dist: PyJWT
|
|
17
20
|
Dynamic: author
|
|
18
21
|
Dynamic: author-email
|
|
19
22
|
Dynamic: classifier
|
|
@@ -62,3 +65,36 @@ cred.json - example
|
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
}
|
|
68
|
+
|
|
69
|
+
using tokens:
|
|
70
|
+
|
|
71
|
+
to protect endpoints by verifying tokens - add protected_methods to that object for example:
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
"car": {
|
|
75
|
+
"allowd_methods": ["GET", "POST", "DELETE", "PUT"],
|
|
76
|
+
"protected_methods": ["GET"],
|
|
77
|
+
"fetch_all": "true",
|
|
78
|
+
"schema": {
|
|
79
|
+
"owner": "VARCHAR(100)",
|
|
80
|
+
"color": "VARCHAR(100)",
|
|
81
|
+
"licence_plate": "INT"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
here when using "GET" to get a car we will need to add a token.
|
|
87
|
+
|
|
88
|
+
in order for this to work a few things need to be set:
|
|
89
|
+
an environment varriable JWT_ALGORITHM should be set.
|
|
90
|
+
the options are:
|
|
91
|
+
- RS256
|
|
92
|
+
- HS256
|
|
93
|
+
if none are set it will default to HS256.
|
|
94
|
+
|
|
95
|
+
if the algorithim being used is HS256 then a variable needs to be set for SECRET_KEY.
|
|
96
|
+
this has to be the same SECRET_KEY that was used for creating the jwt.
|
|
97
|
+
|
|
98
|
+
if the algorithim being used is RS256. a variable needs to be set for SECRET_KEYS_PATH.
|
|
99
|
+
and at that path there needs to be a public.pem
|
|
100
|
+
it has to be the same cert that was used to create the jwt.
|
|
@@ -5,9 +5,9 @@ with open('README.md', encoding='utf-8') as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name='crud-mysql',
|
|
8
|
-
version='0.1.
|
|
8
|
+
version='0.1.7',
|
|
9
9
|
packages=find_packages(),
|
|
10
|
-
install_requires=['mysql-connector-python', 'mysql-database', 'flask'],
|
|
10
|
+
install_requires=['mysql-connector-python', 'mysql-database', 'flask', 'flask_jwt_extended', 'cryptography', 'PyJWT'],
|
|
11
11
|
author='hanna',
|
|
12
12
|
author_email='channashosh@gmail.com',
|
|
13
13
|
description='crud defiend by json',
|
crud_mysql-0.1.6/README.md
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
main.py / app.py - example
|
|
2
|
-
|
|
3
|
-
from flask import Flask
|
|
4
|
-
from flask_cors import CORS
|
|
5
|
-
from crud_mysql import crud
|
|
6
|
-
|
|
7
|
-
app = Flask(__name__)
|
|
8
|
-
|
|
9
|
-
app.register_blueprint(crud)
|
|
10
|
-
|
|
11
|
-
if __name__ == "__main__":
|
|
12
|
-
app.run(host="0.0.0.0", debug=True)
|
|
13
|
-
|
|
14
|
-
cred.json - example
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
"user": {
|
|
18
|
-
"allowd_methods": ["GET", "POST", "DELETE", "PUT"],
|
|
19
|
-
"fetch_all": "true",
|
|
20
|
-
"schema": {
|
|
21
|
-
"name": "VARCHAR(100)",
|
|
22
|
-
"email": "VARCHAR(100)",
|
|
23
|
-
"encrypted_password": "VARCHAR(100)",
|
|
24
|
-
"account_id": "INT",
|
|
25
|
-
"is_active": "INT"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"account": {
|
|
29
|
-
"allowd_methods": ["GET", "POST", "DELETE"],
|
|
30
|
-
"fetch_all": "false",
|
|
31
|
-
"schema": {
|
|
32
|
-
"name": "VARCHAR(100)",
|
|
33
|
-
"subscription_type": "VARCHAR(100)",
|
|
34
|
-
"root_user": "INT"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|