Hello,
Just experimenting with a setup that will allow a user to authenticate via OIDC without having to have a database table for allowed users. Which means that the credentials need to be stored in the database.
Libraries:
- GitHub - tanguilp/plugoid: OpenID Connect Plug for Elixir's Phoenix web framework - Does everything I want, but old and looks no longer maintained. I think it might store stuff in cookies so might have the same problems I am encountering (see below).
- GitHub - DockYard/openid_connect - what I am using. Seems to do the job, no complaints yet.
- GitHub - Erlang-Openid/oidcc: OpenId Connect client library in Erlang - another alternative I just found, no idea what it is like.
I tried storing the claims value in the session. And regularly checking that the “exp” time specified hasn’t been exceeded.
Which seems to work at first, but then I noticed static files don’t download anymore, because the session cookie is now too big:
431 Request Header Fields Too Large
OK, fair enough, probably don’t want to make the request too big. That could be somewhat inefficient, especially for static files. This claims is a map of 9 values:
%{
"at_hash" => "<22 bytes>",
"aud" => "scrooge",
"c_hash" => "<22 bytes>",
"exp" => 1635136662,
"groups" => ["admin"],
"iat" => 1635050262,
"iss" => "https://xxx.example.org",
"name" => "Brian May",
"sub" => "<30 bytes>"
}
So maybe I only need to store important fields that I need, like “name”, “exp”, “sub”, and “groups”. But I worry this could also be a problem.
ETS based sessions, instead of cookie based sessions, might also be a possibility too, I guess. But some of the caveats put me off, e.g. no sharing of sessions between servers.
Does this mean that my goals are a not feasible? Maybe I should just create an db entry for authenticated user, store the required details, and look it up for email, sub id, session id, or something, and have login use a more conventional based approach.
https://hexdocs.pm/phoenix/1.3.0-rc.0/sessions.html#ets
Just curious, as I have some IOT web applications that don’t necessarily need or want a database except for authentication if there is some way to fix up the authentication not to require it also.
Possibly I am not thinking clearly through this, a fresh point of view would be appreciated.
Regards