Created
          July 22, 2020 17:41 
        
      - 
      
 - 
        
Save dvliman/0d2ff81a17482e7933e81eeebcf6cf14 to your computer and use it in GitHub Desktop.  
    buddy auth access rules snippet
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ;; File: src/some_app/middleware.clj | |
| (defn open-gates [request] | |
| true) | |
| (def rules [{:pattern #"^/admin.*" | |
| :handler admin-access | |
| :redirect "/notauthorized"}, | |
| {:pattern #"^\/vclass.*" | |
| :handler user-access | |
| :redirect "/notauthorized"}, | |
| {:pattern #"^\/api.*" | |
| :handler open-gates | |
| :redirect "/notauthorized"}, | |
| {:pattern #"^/user.*" | |
| :handler authenticated?}]) | |
| (defn wrap-base [handler] | |
| (-> ((:middleware defaults) handler) | |
| wrap-auth | |
| (wrap-access-rules {:rules rules :on-error on-error}) | |
| (wrap-authentication (session-backend)) | |
| wrap-flash | |
| (wrap-defaults | |
| (-> site-defaults | |
| (assoc-in [:security :anti-forgery] false) | |
| (assoc-in [:session :store] (ttl-memory-store (* 60 30))))) | |
| wrap-internal-error)) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment