Authentication
νμ κ°μ
λΉλ°λ²νΈ μ 곡 λ° νμΈ
UserCreateionForm
μΆκ° column μ μμ μ₯ logicμμ μΌμΉνλμ§ νμΈ
λΉλ°λ²νΈ μνΈν μ μ₯
User.objects.create_user(username, email=None, password=None)
user.set_password(password)
λ‘κ·ΈμΈ
μ¬μ©μκ° λ‘κ·ΈμΈ ν μ¬λμ΄λ€?
Stateless & Connectless
맀 μμ²μ΄ λ 립 μ¬κ±΄
cookie
κ° μ΄κ±Έ μ΄μ΄μ€λ€!
User Object
core of the authentication system
'superusers'
or admin'staff'
users are just user objects with special attributes set, not different classes of user objects
AbstractBaseUser
AbstractUser
User
Primary attributes of default user
username
password
email
first_name
last_name
Creating Users
Changing Password
1. Using command line
2. Using set_password()
set_password()
Authenticating Users
authenticate(request=None, **credentials)
use it to verify a set of credentials
takes credentials as keyword arguments
username and password for the default cases
returns
User
object if credentials are valid for a backend
μ₯λ°κ΅¬λ
μ¬μ©μ ---> μ₯λ°κ΅¬λ ---> μΏ ν‘
μ¬μ©μ <--- μΏ ν€ <--- μΏ ν‘
μ₯λ°κ΅¬λ ==
cookie
ꡬ맀λ΄μ ==
data
λ‘κ·ΈμΈ == create
λ‘κ·Έμμ == delete
λ‘κ·ΈμΈ Form
AutehticationForm
μ ModelForm μ΄ μλλΌ κ·Έλ₯ Form μ΄λ€!
λ‘κ·ΈμΈ ν¨μ
else
λ¬Έ μ²λ¦¬λ₯Ό 맀λλ½κ² νκΈ° μν΄ μ²«λ²μ§Έif
λ‘ POSTλ₯Ό λ¨Όμ κ±°λ₯Έλ€why?
λ§μ½ GETμ λ¨Όμ κ±°λ₯΄λ©΄, POSTμμ
.is_valid()
μ κ±Έλ¦¬μ§ μκ³else
λ‘ λ¨μ΄μ§λ©΄ λ€μ renderνλ μ½λ μ¨μ€μΌν΄μ!μ¦, *codeμ κ²½μ μ±μ μν΄ POST λ₯Ό λ¨Όμ μ΄λ€!
+
POST
λ‘ λ¨Όμ λΆκΈ°νλ μ΄μ
POST
λ‘ λ¨Όμ λΆκΈ°νλ μ΄μ μ½λμ κ°κ²°μ±
REST API λμ
νμ¬ μ°λ¦¬λ GET & POSTλ§ λμνκ³ μλλ° μ΄νμ RESTful νκ² λ©μλ ꡬμ±ν κ²½μ° GET/POST/PUT/DELETE μ¬λ¬κ°μ λ©μλκ° μ€κ² λκ³ GET methodκ° λ§μ§λ§μμ νΈλ€λ§λλ ννκ° κ°μ₯ κ°κ²°ν μ½λ ꡬμ±μ΄ κ°λ₯!
Message Framework
new
-> κΈ μμ± νμ΄μ§ (form)
create
-> DBμμ μ₯
-> render
-> redirect(μ±κ³΅μ¬λΆ)
-> redirect('articles:index')
HTTPλ requestμ responseμ λ°λ³΅μ΄λ€!
HTTP
stateless (무 μνμ±)
νλ² μμ²μ 보λ΄λ©΄ μν(κ³Όκ±°)λ₯Ό μ μ μμ
λͺ¨λ μμ² & μλ΅μ μΌνμ±μ΄λ€
HTTPλ λ¨μ μ μΈ protocol
connectionless (무 μ°κ²°μ±)
Message Framework
μ΄μ μ μνλ₯Ό λ€μ
Request
&Response
μ λ겨μ€λ€λ κ²μ΄ μλ―Έκ° μλ€Fallback Storage
Cookie κ° μλλ©΄ Session
Dynamic view
Article CRUD
title, content, create_at, updated_at
User CRUD (μ§μ < Django)
+
in memory cache -> ramμ λμλλ cacheλΌκ³ μκ°νλ©΄ λ¨
memcached
redis
κ΅¬κΈ κ΄κ³ μμ΄λ......gdpr
macaddress = κΈ°κΈ°μ 보
Last updated