Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Token_Generation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
harshavardhan.c
Token_Generation
Commits
e3917895
Commit
e3917895
authored
Nov 14, 2022
by
noureen.taj
🖖🏻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: project id conf
parent
f40c048e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
generate_token.py
generate_token.py
+10
-6
No files found.
generate_token.py
View file @
e3917895
...
...
@@ -13,14 +13,15 @@ app = Typer(
jwt
=
JWT
()
def
create_token
(
user_id
,
ip
,
token
,
age
=
Secrets
.
LOCK_OUT_TIME_MINS
):
def
create_token
(
user_id
,
ip
,
token
,
age
=
Secrets
.
LOCK_OUT_TIME_MINS
,
project_id
=
"project_099"
):
"""
This method is to create a cookie
"""
try
:
uid
=
str
(
uuid
.
uuid4
())
.
replace
(
"-"
,
""
)
payload
=
{
"ip"
:
ip
,
"user_id"
:
user_id
,
"token"
:
token
,
"uid"
:
uid
,
"age"
:
age
}
payload
=
{
"ip"
:
ip
,
"user_id"
:
user_id
,
"token"
:
token
,
"uid"
:
uid
,
"age"
:
age
,
"project_id"
:
project_id
}
exp
=
datetime
.
utcnow
()
+
timedelta
(
minutes
=
age
)
_extras
=
{
"iss"
:
Secrets
.
issuer
,
"exp"
:
exp
}
...
...
@@ -38,10 +39,12 @@ def create_token(user_id, ip, token, age=Secrets.LOCK_OUT_TIME_MINS):
raise
Redis_host
:
str
=
typer
.
prompt
(
"Enter Redis Host to continue"
,
default
=
'192.168.0.2
20
'
)
Redis_port
:
int
=
int
(
typer
.
prompt
(
"Enter Redis Port to continue"
,
default
=
'637
9
'
))
Redis_host
:
str
=
typer
.
prompt
(
"Enter Redis Host to continue"
,
default
=
'192.168.0.2
07
'
)
Redis_port
:
int
=
int
(
typer
.
prompt
(
"Enter Redis Port to continue"
,
default
=
'637
7
'
))
Redis_db
:
int
=
int
(
typer
.
prompt
(
"Enter Redis DB to continue"
,
default
=
'9'
))
user_details
:
str
=
typer
.
prompt
(
"Enter User Id to continue"
,
default
=
'user_099'
)
user_details
:
str
=
typer
.
prompt
(
"Enter User Id to continue"
,
default
=
'user_097'
)
project_id
:
str
=
typer
.
prompt
(
"Enter Project ID to continue"
,
default
=
'project_099'
)
ip_details
:
str
=
typer
.
prompt
(
"Enter Ip to continue"
,
default
=
'127.0.0.1'
)
token_age_in_days
:
int
=
int
(
typer
.
prompt
(
"Enter Token Age in days to continue"
,
default
=
'2'
))
login_db
=
redis
.
Redis
(
...
...
@@ -52,5 +55,6 @@ login_db = redis.Redis(
)
age_in_minutes
=
token_age_in_days
*
24
*
60
token_details
=
create_token
(
user_id
=
user_details
,
ip
=
ip_details
,
token
=
Secrets
.
token
,
age
=
age_in_minutes
)
token_details
=
create_token
(
user_id
=
user_details
,
ip
=
ip_details
,
token
=
Secrets
.
token
,
age
=
age_in_minutes
,
project_id
=
project_id
)
typer
.
echo
(
typer
.
style
(
f
"Token Generated for {token_age_in_days} days is {token_details}"
,
fg
=
typer
.
colors
.
GREEN
))
Write
Preview
Markdown
is supported
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