2020년 3월 25일 보안정보 스크래핑

2020년 3월 25일 보안정보 스크래핑 3월 25일 보안정보 스크래핑 ==================================================================== + 주요 취약점 - 메일전송 프로토콜을 이용한 원격 명령어 실행 주의 권고 외 1건 1. 메일전송 프로토콜을 이용한 원격 명령어 실행 주의 권고 최근 OpenSMTPD* 취약점이 발견되는 등 메일전송 프로토콜에서 원격 명령어 실행이 가능하여 주의를 권고함 공격자는 취약점을 악용하여 피해를 발생시킬 수 있으므로, 해결방안을 참고하여 조치 필요 - https://www.krcert.or.kr/data/secNoticeView.do?bulletin_writing_sequence=35302 2. Django 제품 SQL Injection 취약점 보안 업데이트 권고 최근 Django*에서 SQL Injection취약점(CVE-2020-9402)을 악용할 수 있는 개념증명코드(Proof of concept, PoC)가 인터넷상에 공개되어 사용자의 보안 업데이트 필요 - https://www.krcert.or.kr/data/secNoticeView.do?bulletin_writing_sequence=35301 ==================================================================== + 취약점 - Apple Safari 취약점 1. Apple Safari 취약점 Apple Safari security bypass CVE-2020-3885 - https://exchange.xforce.ibmcloud.com/vulnerabilities/178339 Apple Safari security bypass CVE-2020-3887 - https://exchange.xforce.ibmcloud.com/vulnerabilities/178338 Apple Safari inform

[django 번외] 회원가입 기능 만들기

[django 번외] 회원가입 기능 만들기

[django] python django 게시판 만들기 - 회원가입 기능 만들기

간단한 회원가입 기능을 만들어 봅니다.

-----------------------------------------------------------------------------------------------------------------------------------vscode 설치하기 : https://integer-ji.tistory.com/65

python 설치하기 : https://integer-ji.tistory.com/64

git 설치하기 : https://integer-ji.tistory.com/66

vscode 설정하기 : https://integer-ji.tistory.com/81

hello world 띄우기 : https://integer-ji.tistory.com/82

git 초기 설정 : https://integer-ji.tistory.com/83

page 이동 : https://integer-ji.tistory.com/84

word count 실습 ( 1 ) : https://integer-ji.tistory.com/85

word count 실습 ( 2 ) : https://integer-ji.tistory.com/86

python django 게시판 만들기 ( 1 ) : https://integer-ji.tistory.com/89

python django 게시판 만들기 ( 2 ) : https://integer-ji.tistory.com/90

python django 게시판 만들기 ( 3 ) : https://integer-ji.tistory.com/91

python django 게시판 만들기 ( 4 ) : https://integer-ji.tistory.com/93

python django 게시판 만들기 ( 5 ) : https://integer-ji.tistory.com/94

python django 게시판 만들기 ( 6 ) : https://integer-ji.tistory.com/95

python django 게시판 만들기 ( 7 ) : https://integer-ji.tistory.com/97

python django 게시판 만들기 ( 8 ) : https://integer-ji.tistory.com/99

python django 게시판 만들기 ( 9 ) : https://integer-ji.tistory.com/100

python django 게시판 만들기 ( 10 ) : https://integer-ji.tistory.com/101

python django 게시판 만들기 ( 11 ) : https://integer-ji.tistory.com/102

python django 게시판 만들기 ( 12 ) : https://integer-ji.tistory.com/106

python django 게시판 만들기 ( 13 ) : https://integer-ji.tistory.com/107

python django 게시판 만들기 ( 13 ) : https://integer-ji.tistory.com/109

python django 게시판 만들기 ( 14 ) : https://integer-ji.tistory.com/110

-----------------------------------------------------------------------------------------------------------------------------------

member를 관리하기 위한 app 생성

python manage.py startapp crudmember

settings.py에 생성된 app 등록

'crudmember.apps.CrudmemberConfig',

urls.py 등록

from django.urls import path from . import views urlpatterns = [ path('signup/', views.signup, name='signup'), path('login/', views.login, name='login'), path('logout/', views.logout, name='logout'), ]

app 아래에 새로운 urls.py를 만들어 줍니다.

app에 urls.py를 만들어 주었으니

project에도 url import 및 추가

from django.contrib import admin from django.urls import path, include from django.conf import settings from django.conf.urls.static import static import crudapp.views import crudmember.views urlpatterns = [ path('admin/', admin.site.urls), path('', crudapp.views.home, name='home'), path('crudapp/', include('crudapp.urls')), path('crudmember/', include('crudmember.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

templates 만들기

{% extends 'base.html' %} {% block content %} 회원가입 {% csrf_token %} 아이디: 비밀번호: 비밀번호 확인: {% endblock %}

{% extends 'base.html' %} {% block content %} 로그인 {% csrf_token %} 아이디: 비밀번호: {% endblock %}

templates폴더에는 login.html과 signup.html 파일을 만들어 줍니다.

views.py 함수 만들기

from django.shortcuts import render, redirect from django.contrib.auth.models import User from django.contrib import auth # Create your views here. def signup(request): if request.method == 'POST': if request.POST['password1'] == request.POST['password2']: user = User.objects.create_user( request.POST['username'], password=request.POST['password1']) auth.login(request, user) return redirect('home') return render(request, 'signup.html') def login(request): if request.method == 'POST': username = request.POST['username'] password = request.POST['password'] user = auth.authenticate(request, username=username, password=password) if user is not None: auth.login(request, user) return redirect('home') else: return render(request, 'login.html') else: return render(request, 'login.html') def logout(request): auth.logout(request) return redirect('home')

많이 코드가 길어졌습니다...

django에서 제공해주는 auth.models에서 User을 가져옵니다.

이걸 통해서 로그아웃과 로그인을 쉽게 만들어 줍니다.

signup는 request 받은 password1과 password2가 같을 경우에만 회원가입이 진행이 되고

로그인 또한 username과 password가 같을 경우 auth.login을 통해 로그인이 진행됩니다.

base.html 수정

{% if user.is_authenticated %} {{ user.username }}님 반갑습니다! new post logout {% else %} Sign in Sign up {% endif %}

{% if user.is_authenticated %}을 통해서

로그인이 되어있으면 user.username과 logout, 그리고 글을 쓸 수 있게 하고

아닐 경우에는 sign in과 sign up을 출력합니다.

확인

정상적으로 회원가입이 이루어진 뒤 로그인이 되는 모습을 확인할 수 있습니다.

git push 하고 마무리

---

from http://integer-ji.tistory.com/111 by ccl(A) rewrite - 2020-03-21 09:20:11

댓글

이 블로그의 인기 게시물

Django Rest Api 참고

Elasticsearch-dsl 삽질 복기(1)

django 설치 방법