Custom user authentication system

48 views
Skip to first unread message

Mathieu

unread,
May 10, 2012, 11:43:21 AM5/10/12
to Blacklight Development
Hello,
We're trying to develop our own user authentication system and to
integrate it to Blacklight. It uses a TCP connection and don't need a
database. We follow the instructions on the wiki but we encounter a
problem to connect with Blacklights's bookmark. It seems to be a
problem with active record associations.
We added to User Class the line "self.abstract_class = true" to use it
without database (but it inherits from ActiveRecord anyway). It works
fine when a user authenticates but it fails with searches (when the
"existing_bookmark_for" methods is called).

Does Blacklight need a user table with a user modele to authenticate
or can we make it works without ?

thanks,
Mathieu.

Jonathan Rochkind

unread,
May 10, 2012, 12:05:19 PM5/10/12
to blacklight-...@googlegroups.com, Mathieu
It _ought_ not to need a user table with a user model, I _think_.
However, I could be wrong, or there could be bugs in BL.

I think the easiest thing to do would be to include a User model. That
doesn't mean the user model needs to play any part in authentication --
it's just a local record of a user account in your Blacklight app.

I don't authenticate against a database either. But I do have a user
table in the database with a User active record model. Once a user is
authenticated, I have some 'unique id' for the user from my external
authentication -- I use that external ID to look up a user record in my
local table, and create one if it doesn't exist, and then set that user
record as current_user.

I would recommend that as your best bet. It _ought_ to be possible to
do what you originally described, I _think_ (but could be wrong), but
might take a lot of hacking, and possibly rearchitecting of BL somewhat
if it turns out it wasn't as flexible as we thought.

Your "user" ActiveRecord model _can_ be called something other than
User, if you want to reserve the name "User" for something else. That is
a feature in BL already, and that feature ought to be working, or ought
not to be that hard for us or you to fix if it's buggy.

Jonathan

Mathieu

unread,
May 23, 2012, 8:10:40 AM5/23/12
to Blacklight Development
Hello,
thanks for your reply. Sorry to be late, I was trying to test
Blacklight with a user table.
I don't succeed to integrate our user model and I have the same errors
than without user table ( message : "undefined method `[]' for
nil:NilClass" when the method "existing_bookmark_for(document.id)" is
called in document view)

Firstly, routes for /bookmarks and /saved_searches are not found.
However, when I execute the command "rake routes" these two routes are
indicated.

Do you have an idea for these problems ?

Thanks,
Mathieu

Jonathan Rochkind

unread,
May 23, 2012, 11:09:40 AM5/23/12
to blacklight-...@googlegroups.com, Mathieu
I don't have any ideas, sorry. It's gonna take some debugging. It's
possibly a bug in BL, it's possibly something not done right in your
local app, it's possibly a documentation bug where the docs don't
accurately explain what you have to do.

Sorry.

Jessie Keck

unread,
May 23, 2012, 12:20:02 PM5/23/12
to blacklight-...@googlegroups.com
Hi Mathieu,
It may also help if you put your user model and the stack trace you're seeing into a gist ( http://gist.github.com ). That can let us see the code you're working with and may help us figure out what is happening.

Thanks,
- Jessie
> --
> You received this message because you are subscribed to the Google Groups "Blacklight Development" group.
> To post to this group, send email to blacklight-...@googlegroups.com.
> To unsubscribe from this group, send email to blacklight-develo...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/blacklight-development?hl=en.
>

Mathieu

unread,
May 24, 2012, 8:13:08 AM5/24/12
to Blacklight Development
Hi,
I found a solution for user model. It was a bug when initializing a
user object, now it works!

But routes for bookmarks and saved_searches don't work. I made an
update of the local applications with blacklight 3.4.2 but it seems to
have no effect. In the output of command "rake routes", bookmarks ans
saved_searches are indicated.

This is my routes.rb file :
https://gist.github.com/2781198

thanks,
Mathieu.







On 23 mai, 18:20, Jessie Keck <jk...@stanford.edu> wrote:
> Hi Mathieu,
> It may also help if you put your user model and the stack trace you're seeing into a gist (http://gist.github.com).  That can let us see the code you're working with and may help us figure out what is happening.

Mathieu

unread,
Jun 1, 2012, 9:31:56 AM6/1/12
to Blacklight Development
Hello,
It's ok now. In my User controller I have a current_user method but
It's better to put it in application controller to work fine with
bookmarks.

Thanks,
Mathieu.
Reply all
Reply to author
Forward
0 new messages