-
Notifications
You must be signed in to change notification settings - Fork 0
/
jwt_토큰_생성_및_사용_과정.drawio
121 lines (121 loc) · 10.2 KB
/
jwt_토큰_생성_및_사용_과정.drawio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<mxfile host="65bd71144e">
<diagram id="awSVDGon45IlIPbuSrbu" name="Page-1">
<mxGraphModel dx="594" dy="584" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="583" pageHeight="827" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="2" target="3" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="23" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;curved=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="2" target="21">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="2" value="" style="shape=actor;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="110" y="280" width="40" height="60" as="geometry"/>
</mxCell>
<mxCell id="3" value="/login" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="292" y="280" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="5" value="-d<br>username<br>password" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="200" y="330" width="40" height="20" as="geometry"/>
</mxCell>
<mxCell id="6" value="POST" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="200" y="282" width="40" height="20" as="geometry"/>
</mxCell>
<mxCell id="12" value="login()" style="rounded=1;whiteSpace=wrap;html=1;arcSize=44;" parent="1" vertex="1">
<mxGeometry x="292" y="346" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="13" value="routers/<br>authentication.py" style="rounded=1;whiteSpace=wrap;html=1;arcSize=0;" parent="1" vertex="1">
<mxGeometry x="292" y="220" width="120" height="50" as="geometry"/>
</mxCell>
<mxCell id="14" value="- db 에서 유저이름 가져오기<br>- request 유저이름과 같은지 확인<br>- 패스워드 해시가 같은지 확인<br>- 엑세스 토큰 생성<br>- 엑세스 토큰 리턴" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="262" y="382" width="180" height="126" as="geometry"/>
</mxCell>
<mxCell id="16" value="create_access_token()" style="rounded=1;whiteSpace=wrap;html=1;arcSize=44;" parent="1" vertex="1">
<mxGeometry x="480" y="346" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="18" value="jwttoken.py" style="rounded=1;whiteSpace=wrap;html=1;arcSize=0;" parent="1" vertex="1">
<mxGeometry x="482" y="220" width="120" height="50" as="geometry"/>
</mxCell>
<mxCell id="19" value="" style="curved=1;endArrow=classic;html=1;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="356" y="461" as="sourcePoint"/>
<mxPoint x="450" y="432" as="targetPoint"/>
<Array as="points">
<mxPoint x="406" y="461"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="20" value="- jwt.encode(<br>&nbsp; &nbsp; &nbsp; &nbsp; {인코딩할 유저네임, 만료시간},<br>&nbsp; &nbsp; &nbsp; &nbsp; 시크릿키,<br>&nbsp; &nbsp; &nbsp; &nbsp; 알고리즘<br>&nbsp; &nbsp; &nbsp; &nbsp; )" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="455" y="382" width="180" height="126" as="geometry"/>
</mxCell>
<mxCell id="21" value="/blog" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="180" y="620" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="24" value="GET" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="140" y="490" width="40" height="20" as="geometry"/>
</mxCell>
<mxCell id="25" value="- 쿼리파라미터 <br>current_user : schemas.User = Depends(oauth2.get_current_user)<br>&nbsp;를 사용해 credential 이 일치하는지 점검" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="135" y="740" width="210" height="100" as="geometry"/>
</mxCell>
<mxCell id="26" value="all()" style="rounded=1;whiteSpace=wrap;html=1;arcSize=44;" vertex="1" parent="1">
<mxGeometry x="180" y="683" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="27" value="oauth2.py" style="rounded=1;whiteSpace=wrap;html=1;arcSize=0;" vertex="1" parent="1">
<mxGeometry x="418" y="590" width="120" height="25" as="geometry"/>
</mxCell>
<mxCell id="28" value="routers/blog.py" style="rounded=1;whiteSpace=wrap;html=1;arcSize=0;" vertex="1" parent="1">
<mxGeometry x="180" y="590" width="120" height="25" as="geometry"/>
</mxCell>
<mxCell id="29" value="main.py" style="rounded=1;whiteSpace=wrap;html=1;arcSize=0;" vertex="1" parent="1">
<mxGeometry x="180" y="530" width="120" height="25" as="geometry"/>
</mxCell>
<mxCell id="31" value="include_router()" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="195" y="560" width="90" height="20" as="geometry"/>
</mxCell>
<mxCell id="33" value="get_current_user()" style="rounded=1;whiteSpace=wrap;html=1;arcSize=44;" vertex="1" parent="1">
<mxGeometry x="418" y="635" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="34" value="- oauth2_scheme 변수를 통해 Oauth2PasswordBearer() 인스턴스를 만들고 /login 경로에서 로그인한 정보를 선언<br><br>- jwttoken.verify() 를 통해, 맞으면 진행, 틀리면 에러 출력" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="373" y="700" width="210" height="100" as="geometry"/>
</mxCell>
<mxCell id="35" value="" style="curved=1;endArrow=classic;html=1;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="310" y="770" as="sourcePoint"/>
<mxPoint x="410" y="670" as="targetPoint"/>
<Array as="points">
<mxPoint x="350" y="770"/>
<mxPoint x="340" y="720"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="37" value="jwttoken.py" style="rounded=1;whiteSpace=wrap;html=1;arcSize=0;" vertex="1" parent="1">
<mxGeometry x="645" y="590" width="120" height="25" as="geometry"/>
</mxCell>
<mxCell id="38" value="verify_token()" style="rounded=1;whiteSpace=wrap;html=1;arcSize=44;" vertex="1" parent="1">
<mxGeometry x="645" y="635" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="39" value="- python-jose 의 jwt, JWTError 를 활용해 주어진 토큰을 시크릿키와 알고리즘으로 jwt.decode() 했을 때 출력되는 payload 에서 email 이 없으면 에러출력, 있으면 진행" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="600" y="700" width="210" height="100" as="geometry"/>
</mxCell>
<mxCell id="40" value="" style="curved=1;endArrow=classic;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" target="38">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="470" y="760" as="sourcePoint"/>
<mxPoint x="520" y="710" as="targetPoint"/>
<Array as="points">
<mxPoint x="570" y="760"/>
<mxPoint x="600" y="760"/>
<mxPoint x="590" y="710"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="43" value="main.py" style="rounded=1;whiteSpace=wrap;html=1;arcSize=0;" vertex="1" parent="1">
<mxGeometry x="292" y="160" width="120" height="25" as="geometry"/>
</mxCell>
<mxCell id="44" value="include_router()" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="307" y="190" width="90" height="20" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>