Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3253725

Browse files
committed
fastapi jwt token api
1 parent066869c commit3253725

21 files changed

+195
-548
lines changed

‎.env‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
DATABASE_PORT=6500
2-
POSTGRES_PASSWORD=password123
1+
DATABASE_PORT=5432
2+
POSTGRES_PASSWORD=postgres
33
POSTGRES_USER=postgres
4-
POSTGRES_DB=fastapi
5-
POSTGRES_HOST=postgres
4+
POSTGRES_DB=fastapi_challenge
5+
POSTGRES_HOST=localhost
66
POSTGRES_HOSTNAME=127.0.0.1
77

88
ACCESS_TOKEN_EXPIRES_IN=15
@@ -11,13 +11,5 @@ JWT_ALGORITHM=RS256
1111

1212
CLIENT_ORIGIN=http://localhost:3000
1313

14-
VERIFICATION_SECRET=my-email-verification-secret
15-
16-
EMAIL_HOST=smtp.mailtrap.io
17-
EMAIL_PORT=587
18-
EMAIL_USERNAME=4aeca0c9318dd2
19-
EMAIL_PASSWORD=a987a0e0eac00d
20-
EMAIL_FROM=admin@admin.com
21-
22-
JWT_PRIVATE_KEY=LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlCT2dJQkFBSkJBSSs3QnZUS0FWdHVQYzEzbEFkVk94TlVmcWxzMm1SVmlQWlJyVFpjd3l4RVhVRGpNaFZuCi9KVHRsd3h2a281T0pBQ1k3dVE0T09wODdiM3NOU3ZNd2xNQ0F3RUFBUUpBYm5LaENOQ0dOSFZGaHJPQ0RCU0IKdmZ2ckRWUzVpZXAwd2h2SGlBUEdjeWV6bjd0U2RweUZ0NEU0QTNXT3VQOXhqenNjTFZyb1pzRmVMUWlqT1JhUwp3UUloQU84MWl2b21iVGhjRkltTFZPbU16Vk52TG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RSURBUUFCCi0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQ==

‎.env.example‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
DATABASE_PORT=6500
2+
POSTGRES_PASSWORD=password123
3+
POSTGRES_USER=postgres
4+
POSTGRES_DB=fastapi
5+
POSTGRES_HOST=postgres
6+
POSTGRES_HOSTNAME=127.0.0.1
7+
8+
ACCESS_TOKEN_EXPIRES_IN=15
9+
REFRESH_TOKEN_EXPIRES_IN=60
10+
JWT_ALGORITHM=RS256
11+
12+
CLIENT_ORIGIN=http://localhost:3000
13+
14+
15+
JWT_PRIVATE_KEY=LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlCT2dJQkFBSkJBSSs3QnZUS0FWdHVQYzEzbEFkVk94TlVmcWxzMm1SVmlQWlJyVFpjd3l4RVhVRGpNaFZuCi9KVHRsd3h2a281T0pBQ1k3dVE0T09wODdiM3NOU3ZNd2xNQ0F3RUFBUUpBYm5LaENOQ0dOSFZGaHJPQ0RCU0IKdmZ2ckRWUzVpZXAwd2h2SGlBUEdjeWV6bjd0U2RweUZ0NEU0QTNXT3VQOXhqenNjTFZyb1pzRmVMUWlqT1JhUwp3UUloQU84MWl2b21iVGhjRkltTFZPbU16Vk52TGxWTW02WE5iS3B4bGh4TlpUTmhBaUVBbWRISlpGM3haWFE0Cm15QnNCeEhLQ3JqOTF6bVFxU0E4bHUvT1ZNTDNSak1DSVFEbDJxOUdtN0lMbS85b0EyaCtXdnZabGxZUlJPR3oKT21lV2lEclR5MUxaUVFJZ2ZGYUlaUWxMU0tkWjJvdXF4MHdwOWVEejBEWklLVzVWaSt6czdMZHRDdUVDSUVGYwo3d21VZ3pPblpzbnU1clBsTDJjZldLTGhFbWwrUVFzOCtkMFBGdXlnCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0t
16+
JWT_PUBLIC_KEY=LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZ3d0RRWUpLb1pJaHZjTkFRRUJCUUFEU3dBd1NBSkJBSSs3QnZUS0FWdHVQYzEzbEFkVk94TlVmcWxzMm1SVgppUFpSclRaY3d5eEVYVURqTWhWbi9KVHRsd3h2a281T0pBQ1k3dVE0T09wODdiM3NOU3ZNd2xNQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQ==

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
__pycache__
22
venv/
3-
# .env
3+
.venv
4+
.env

‎Makefile‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎alembic/env.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ def run_migrations_online() -> None:
7979
ifcontext.is_offline_mode():
8080
run_migrations_offline()
8181
else:
82-
run_migrations_online()
82+
run_migrations_online()
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""creat users table
2+
3+
Revision ID: 10d12c9e7043
4+
Revises:
5+
Create Date: 2022-11-19 20:29:26.582229
6+
7+
"""
8+
fromalembicimportop
9+
importsqlalchemyassa
10+
fromsqlalchemy.dialectsimportpostgresql
11+
12+
# revision identifiers, used by Alembic.
13+
revision='10d12c9e7043'
14+
down_revision=None
15+
branch_labels=None
16+
depends_on=None
17+
18+
19+
defupgrade()->None:
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.create_table('users',
22+
sa.Column('id',postgresql.UUID(as_uuid=True),nullable=False),
23+
sa.Column('name',sa.String(),nullable=False),
24+
sa.Column('username',sa.String(),nullable=False),
25+
sa.Column('password',sa.String(),nullable=False),
26+
sa.Column('created_at',sa.TIMESTAMP(timezone=True),server_default=sa.text('now()'),nullable=False),
27+
sa.Column('updated_at',sa.TIMESTAMP(timezone=True),server_default=sa.text('now()'),nullable=False),
28+
sa.PrimaryKeyConstraint('id'),
29+
sa.UniqueConstraint('username')
30+
)
31+
op.create_table('projects',
32+
sa.Column('id',postgresql.UUID(as_uuid=True),nullable=False),
33+
sa.Column('username',sa.String(),nullable=False),
34+
sa.Column('title',sa.String(),nullable=False),
35+
sa.Column('zip_code',sa.Integer(),nullable=False),
36+
sa.Column('cost',sa.Float(precision=2),nullable=False),
37+
sa.Column('done',sa.Boolean(),nullable=True),
38+
sa.Column('deadline',sa.DateTime(),nullable=False),
39+
sa.Column('created_at',sa.TIMESTAMP(timezone=True),server_default=sa.text('now()'),nullable=False),
40+
sa.Column('updated_at',sa.TIMESTAMP(timezone=True),server_default=sa.text('now()'),nullable=False),
41+
sa.ForeignKeyConstraint(['username'], ['users.username'],ondelete='CASCADE'),
42+
sa.PrimaryKeyConstraint('id')
43+
)
44+
# ### end Alembic commands ###
45+
46+
47+
defdowngrade()->None:
48+
# ### commands auto generated by Alembic - please adjust! ###
49+
op.drop_table('projects')
50+
op.drop_table('users')
51+
# ### end Alembic commands ###

‎alembic/versions/15770e820938_created_users_table.py‎

Lines changed: 0 additions & 40 deletions
This file was deleted.

‎alembic/versions/1c7984990e1d_created_posts_table.py‎

Lines changed: 0 additions & 39 deletions
This file was deleted.

‎alembic/versions/39256113e8e5_added_verification_code.py‎

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎alembic/versions/4917da928a79_added_post_table.py‎

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp