기본 콘텐츠로 건너뛰기

meteor 0.3.9 에서 사용자 인증을 써보자.

예전에 everyAuth 에 대한 글을 쓴적이 있는데
https://github.com/meteor/meteor/wiki/Getting-Started-with-Auth
meteor wiki에 위와 같은 글이 있더라.
발빠르다 meteor. 투자받더니 탄력이 붙었는지 쭉쭉 잘나가는군.
일단 meteor 설치부터 다시하자.
이전에 Quick start 가이드대로

curl https://install.meteor.com | /bin/sh

이렇게 설치했지만.
이번엔 git 에서 auth Branch를 따서 갈 것이므로 수동 설치하자.

git clone git://github.com/meteor/meteor.git
cd meteor
수동설치래봤자 적절한 곳에 clone 하고
인스톨 하는게 전부인데.

auth는 다른 branch에 있기 때문에 일단 clone 하고 해당 경로에 진입만한 상태에서
git branch -r 로 리모트 브랜치를 확인해보자

  origin/HEAD -> origin/master
  origin/auth
  origin/auth-email
  origin/auth-test-isolation
  origin/auth-twitter
  origin/avital
  origin/avital-remove
  origin/avital-watch
  origin/david-handlebars
  origin/dev-bundle-bump
  origin/devel
  origin/email
  origin/forms
  origin/jade
  origin/master
  origin/release-0.1
  origin/release-0.1-templates
  origin/spark
  origin/spiderable
  origin/test-isolation
  origin/version-bump
  origin/webgl
  origin/wrappedjs
  origin/{ref}squashed-auth

이렇게 주욱 나올텐데 우리가 필요한 건

  origin/auth

요놈이다.
git checkout -t origin/auth
(0.4.2 기준 git checkout -t origin/devel 로 변경)
해서 브랜치를 변경하고

$ git branch
* auth
  master

이렇게 확인해서 auth로 옮겨간 것을 확인하고 install.sh 를 실행해주자.
./install.sh
그 다음 내용을 확인해보면


$ meteor list
absolute-url            Generate absolute URLs pointing to the application
accounts                A user account system
accounts-facebook       Login service for Facebook accounts
accounts-google         Login service for Google accounts
accounts-passwords      Password support for accounts.
accounts-twitter        Login service for Twitter accounts
accounts-ui             Simple templates to add login widgets to an app.
accounts-weibo          Login service for Sina Weibo accounts
amplify                 Cross browser API for Persistant Storage, PubSub and Req
autopublish             Automatically publish all data in the database to every
backbone                A minimalist client-side MVC framework
bootstrap               UX/UI framework from Twitter
code-prettify           Syntax highlighting of code, from Google
coffeescript            Javascript dialect with fewer braces and semicolons
email                   Send email messages
force-ssl               Require this application always use transport layer encr
handlebars              Simple semantic templating language
htmljs                  Easy macros for generating DOM elements in Javascript
http                    Make HTTP calls to remote servers
insecure                Allow all database writes by default
jquery                  Manipulate the DOM using CSS selectors
jquery-history          pushState module from the jQuery project
jquery-layout           Easily create arbitrary multicolumn layouts
jquery-waypoints        Execute a function when the user scrolls past an element
less                    The dynamic stylesheet language.
localstorage-polyfill   Simulates the localStorage API on IE 6,7 using userData
madewith                Made With Meteor badge
sass                    Sassy CSS pre-processor.
showdown                Markdown-to-HTML processor
spiderable              Makes the application crawlable to web spiders.
stylus                  Expressive, dynamic, robust CSS.
underscore              Collection of small helper functions (map, each, bind, .

못보던 package들이 많이 생겼는데 accounts 라는 것들이 보인다. 심지어 weibo 도 있네;;

여기까지 왔으면 이제 사용하면 된다.


meteor create auth_example
cd auth_example
해서 만들고
meteor add accounts-google accounts-facebook accounts-twitter accounts-passwords accounts-ui
google, facebook, twitter, 일반인증까지 전부 넣자.

auth_example.html 을 열어서

<head>
  <title> auth_example </title>
</head>

<body>
  {{> loginButtons}}
  {{> hello}}
</body>

<template name="hello">
  <h1>Hello World!</h1>
  {{greeting}}
  <input type="button" value="Click" />
</template>


loginButtons 라는 template 을 추가해주자.
아마 브라우저에 Sign in 이라는 링크가 보일테고
Sign in with Facebook 같은 걸 누르면

Facebook API key not set. Configure app details with Meteor.accounts.facebook.config() and Meteor.accounts.facebook.setSecret()

이렇게 나올거다.
설정해주자.
https://developers.facebook.com/apps/<APP_ID>/summary?save=1 에서 만들어놓았던

App ID, App Secret, Website with Facebook Login 의 URL

이렇게 세가지를 가져와서
client/server 양쪽에 들어가는 공통 js 에
Meteor.accounts.facebook.config(APP_ID, APP_URL);

App ID, URL 을 각각 넣어주고
server 쪽 js 에
Meteor.accounts.facebook.setSecret(APP_SECRET);

App Secret 을 넣어준다. 당연히 Secret 은 노출되면 안되니까.

이번 업데이트로 필요없어졌다. app정보는 Collection 안에 들어간다. http://spectrumdig.blogspot.kr/2012/09/meteor-auth-branch-922.html
내용에 다시 정리하였다.

나머지 내용은
https://github.com/meteor/meteor/wiki/Getting-Started-with-Auth 를 참조하자.

(0.4.2 관련 최신 내용)
http://spectrumdig.blogspot.kr/2012/10/meteor-auth-branch-rc-release-candidated.html

댓글

  1. help me~~ same problem!
    =========================================================
    hoho@hoho-VirtualBox:~/meteor$ sudo ./install.sh
    Installing in /usr/local
    It's the first time you've run Meteor from a git checkout.
    I will download a kit containing all of Meteor's dependencies.

    curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

    gzip: stdin: unexpected end of file
    tar: Child returned status 1
    tar: Error is not recoverable: exiting now
    Failed to install dependency kit.

    답글삭제
  2. Error when Installing Meteor in Ubuntu
    curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure Installation failed.
    에러가 나서 찾아보니
    $ openssl s_client -connect install.meteor.com:443
    실행해서 뭔가 바꿔주라고 하는거 같은데
    저는 어떻게 하라는건지 잘 이해가 안가네요 ㅠㅠ

    http://pastebin.com/AdvXTuH5

    답글삭제
  3. 대장님 해결했습니다.
    git clone 이후
    cd meteor
    ./admin/gernerate-dev-bundle.sh
    를 한번 돌려주고
    ./install.sh 하니 되네요
    보니까 왠 ubuntu ntfs 파일시스템에서 생기는 문제 같더군요 ㅎㅎ
    http://frauzufall.de/2012/meteor-ubuntu-ntfs/

    답글삭제
    답글
    1. 12.04 에선 해야되나 보더라구요. 11버전 대에선 그냥 되었는데.

      삭제

댓글 쓰기

이 블로그의 인기 게시물

MQTT Broker Mosquitto 설치 후 설정

우분투 기준 $ sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa $ sudo apt-get update 하고 $ sudo apt-get install mosquitto 으로 설치하면 서비스까지 착실하게 올라간다. 설치는 간단한데 사용자를 만들어야한다. /etc/mosquitto/mosquitto.conf 파일에서 권한 설정을 변경하자. allow_anonymous false 를 추가해서 아무나 못들어오게 하자. $ service mosquitto restart 서비스를 재시작. 이제 사용자를 추가하자. mosquitto_passwd <암호파일 경로명> <사용자명> 하면 쉽게 만들 수 있다. # mosquitto_passwd /etc/mosquitto/passwd admin Password:  Reenter password:  암호 넣어준다. 두번 넣어준다. 이제 MQTT 약을 열심히 팔아서 Broker 사글세방 임대업을 하자.

cURL로 cookie를 다루는 법

http://stackoverflow.com/questions/22252226/passport-local-strategy-and-curl 레거시 소스를 보다보면 인증 관련해서 cookie를 사용하는 경우가 있는데 가령 REST 서버인 경우 curl -H "Content-Type: application/json" -X POST -d '{"email": "aaa@bbb.com", "pw": "cccc"}' "http://localhost/login" 이렇게 로그인이 성공이 했더라도 curl -H "Content-Type: application/json" -X GET -d '' "http://localhost/accounts/" 이런 식으로 했을 때 쿠키를 사용한다면 당연히 인증 오류가 날 것이다. curl의 --cookie-jar 와 --cookie 옵션을 사용해서 cookie를 저장하고 꺼내쓰자. 각각 옵션 뒤엔 저장하고 꺼내쓸 파일이름을 임의로 지정하면 된다. 위의 과정을 다시 수정해서 적용하면 curl -H --cookie-jar jarfile "Content-Type: application/json" -X POST -d '{"email": "aaa@bbb.com", "pw": "cccc"}' "http://localhost/login" curl -H --cookie jarfile "Content-Type: application/json" -X GET -d '' "http://localhost/accounts/" 이렇게 사용하면

OS X 터미널에서 tmux 사용시 pane 크기 조절

http://superuser.com/a/660072  글 참조. OS X 에서 tmux 사용시 나눠놓은 pane 크기 조정할 때 원래는 ctrl+b, ctrl+↑←→↓ 로 사이즈를 조정하는데 기본 터미널 키 입력이 조금 문제가 있다. 키 매핑을 다시 하자 Preferences(cmd+,) > Profile >  변경하고자 하는 Theme 선택 > Keyboards 로 들어가서 \033[1;5A \033[1;5B \033[1;5C \033[1;5D 를 순서대로 ↑↓→←순으로 매핑이 되도록 하면 된다. +를 누르고 Key에 해당 화살표키와 Modifier에 ctrl 선택 한 후 <esc>, [, 1, ;, 5 까지 한키 한키 입력 후 A,B,C,D를 써준다. 잘못 입력했을 땐 당황하지 말고 Delete on character 버튼을 눌러 수정하도록 하자. 그리고 다시 tmux에서 ctrl+b, ctrl+↑←→↓로 사이즈를 조절해보자. 잘 된다.