Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sakshi Agrawal
gkcore
Commits
155afed1
Commit
155afed1
authored
Oct 10, 2016
by
ishan masdekar
Browse files
Now signature(secretcode) is a 2560 bits RSA private key.
parent
c41beec4
Changes
2
Hide whitespace changes
Inline
Side-by-side
gkcore/views/api_organisation.py
View file @
155afed1
...
...
@@ -39,7 +39,7 @@ from sqlalchemy import and_
import
jwt
import
gkcore
from
gkcore.models.meta
import
dbconnect
from
Crypto.PublicKey
import
RSA
@
view_defaults
(
route_name
=
'organisations'
)
class
api_organisation
(
object
):
...
...
@@ -85,6 +85,14 @@ class api_organisation(object):
dataset
=
self
.
request
.
json_body
orgdata
=
dataset
[
"orgdetails"
]
userdata
=
dataset
[
"userdetails"
]
result
=
self
.
con
.
execute
(
select
([
func
.
count
(
gkdb
.
organisation
.
c
.
orgcode
).
label
(
'ocount'
)]))
orgcount
=
result
.
fetchone
()
if
orgcount
[
"ocount"
]
==
0
:
key
=
RSA
.
generate
(
2560
)
privatekey
=
key
.
exportKey
(
'PEM'
)
sig
=
{
"secretcode"
:
privatekey
}
gkcore
.
secret
=
privatekey
result
=
self
.
con
.
execute
(
gkdb
.
signature
.
insert
(),[
sig
])
result
=
self
.
con
.
execute
(
gkdb
.
organisation
.
insert
(),[
orgdata
])
if
result
.
rowcount
==
1
:
code
=
self
.
con
.
execute
(
select
([
gkdb
.
organisation
.
c
.
orgcode
]).
where
(
and_
(
gkdb
.
organisation
.
c
.
orgname
==
orgdata
[
"orgname"
],
gkdb
.
organisation
.
c
.
orgtype
==
orgdata
[
"orgtype"
],
gkdb
.
organisation
.
c
.
yearstart
==
orgdata
[
"yearstart"
],
gkdb
.
organisation
.
c
.
yearend
==
orgdata
[
"yearend"
])))
...
...
initdb.py
View file @
155afed1
...
...
@@ -39,13 +39,6 @@ After creating all tables, it will also create the signature based on timestamp
eng
=
dbconnect
()
metadata
.
create_all
(
eng
)
print
"database created successfully"
curtime
=
datetime
.
datetime
.
now
()
str_time
=
str
(
curtime
.
microsecond
)
new_microsecond
=
str_time
[
0
:
2
]
secret
=
str
(
curtime
.
year
)
+
str
(
curtime
.
month
)
+
str
(
curtime
.
day
)
+
str
(
curtime
.
hour
)
+
str
(
curtime
.
minute
)
+
str
(
curtime
.
second
)
+
new_microsecond
eng
.
execute
(
"insert into signature values(%s)"
%
secret
)
eng
.
execute
(
"alter table groupsubgroups add foreign key (subgroupof) references groupsubgroups(groupcode)"
)
print
"secret signature generated"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment