2014-09-30 4 views
1

표준 사용자 이름/비밀번호 쌍으로 사용자를 인증하는 웹 앱을 구축 중이지만 일부 백그라운드 파일 처리를 위해 Dropbox 및/또는 Google 드라이브에 대한 액세스 권한을 부여해야합니다.다른 URL에 대한 다른 친구 워크 플로우

나는 friend-oauth2를 사용하고 싶었다.에 사용자가 로그인 할 friend를 사용하고 있지만 다른 URL에 대해 서로 다른 friend 워크 플로우를하는 방법을 모르겠어요. 내가하고 싶은 무엇

은 다음과 같습니다

  1. /users/*oauth2/workflow
  2. 공공 다른 URL로 보호 workflows/interactive-form
  3. /dropbox/*/gdrive/*로 보호 I 포인트를 수행하는 방법을 알고

1과 3 (friend/authenticatefriend/authorize)하지만 단서가 없습니다. # 2. 도와주세요.

답변

2

라우트를 다른 미들웨어 정의와 별도로 포장해야합니다. 여기서 경로 정의는 compojure 사용 예이다 : (다른 경로에 대해 서로 다른 미들웨어에 노트 this answer 덕분)

(defroutes interactive-routes* 
    ; Put your interactive routes here 
    ; ... 
) 
(defroutes oauth-routes* 
    ; Put your oauth routes here 
    ; ... 
) 

(def interactive-routes 
    (-> #'interactive-routes* 
    (friend/authenticate {:credential-fn (partial creds/bcrypt-credential-fn users) 
          :workflows [(workflows/interactive-form)]}) 
)) 
(def oauth-routes 
    (-> #'oauth-routes* 
    (friend/authenticate {:credential-fn (partial creds/bcrypt-credential-fn users) 
          :workflows [(oauth2/workflow)]}) 
)) 

(defroutes all-routes 
    (ANY "*" [] interactive-routes) 
    (ANY "*" [] oauth-routes) 

; Then do what you normally would with `all-routes` (e.g., wrap with more middleware, pass to ring server) 

관련 문제