Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6694169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:04:14+00:00 2026-05-26T06:04:14+00:00

I’m having trouble with my Clojure server middlewares. My app has the following requirements:

  • 0

I’m having trouble with my Clojure server middlewares. My app has the following requirements:

  • Some routes should be accessible with no problems. Others require basic authentication, so I’d like to have an authentication function that sits in front of all the handler functions and makes sure the request is verified. I’ve been using the ring-basic-authentication handler for this, especially the instructions on how to separate your public and private routes.

  • However, I’d also like the params sent in the Authorization: header to be available in the route controller. For this I’ve been using Compojure’s site function in compojure.handler, which puts variables in the :params dictionary of the request (see for example Missing form parameters in Compojure POST request)

However I can’t seem to get both 401 authorization and the parameters to work at the same time. If I try this:

; this is a stripped down sample case:

(defn authenticated?
  "authenticate the request"
  [service-name token]
  (:valid (model/valid-service-and-token service-name token)))

(defroutes token-routes
  (POST "/api/:service-name/phone" request (add-phone request)))

(defroutes public-routes
  controller/routes
  ; match anything in the static dir at resources/public
  (route/resources "/"))

(defroutes authviasms-handler
  public-routes
  (auth/wrap-basic-authentication 
             controller/token-routes authenticated?))

;handler is compojure.handler
(def application (handler/site authviasms-handler))

(defn start [port]
  (ring/run-jetty (var application) {:port (or port 8000) :join? false}))

the authorization variables are accessible in the authenticated? function, but not in the routes.

Obviously, this isn’t a very general example, but I feel like I’m really spinning my wheels and just making changes at random to the middleware order and hoping things work. I’d appreciate some help both for my specific example, and learning more about how to wrap middlewares to make things execute correctly.

Thanks,
Kevin

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:04:15+00:00Added an answer on May 26, 2026 at 6:04 am

    AFAIK, ring.middleware.basic-authentication doesn’t read anything from the :params in request and ring.core.request/site doesn’t put anything authentication-related there either.

    But in any ring handler, you can still access the headers. Something like:

    (GET "/hello" 
      {params :params headers :headers} 
      (str "your authentication is " (headers "authentication") 
           " and you provided " params))
    

    Similarly, you can use that to write your own middleware to put authentication-related stuff in params, if you really want to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.