[rabbitmq-discuss] custom plugin debugging

Prabodh Upreti prabodh.upreti at vce.com
Thu Nov 8 23:56:09 GMT 2012


I have just taken Simon's code

check_user_login(Username, AuthProps) ->
    
    case http_get(q(user_path, [{ticket, Username}|AuthProps])) of
        {error, _} = E  -> E;
        deny            -> {refused, "Denied by HTTP plugin", []};
        "allow" ++ Rest -> Tags = [list_to_atom(T) ||
                                      T <- string:tokens(Rest, " ")],
                           {ok, #user{username     = Username,
                                      tags         = Tags,
                                      auth_backend = ?MODULE,
                                      impl         = none}};
        Other           -> {error, {bad_response, Other}}
    end.


http_get(Path) ->
    inets:start(),
    ssl:start(),
    case httpc:request(get, {Path, []}, ?HTTPC_OPTS, []) of
        {ok, {{_HTTP, Code, _}, _Headers, Body}} ->
            case Code of
                200 -> case parse_resp(Body) of
                           {error, _} = E -> E;
                           Resp           -> Resp
                       end;
                _   -> {error, {Code, Body}}
            end;
        {error, _} = E ->
            E
    end.

q(PathName, token) ->
    {ok, Path} = application:get_env(rabbitmq_cas_authen, PathName),
    R = Path ++ "?ticket=" ++ token,
    R.


>>>>As you can see, I have modified q to format with ticket???? for the CAS
server.

on http_get

http_get(Path) ->
    inets:start(),
    ssl:start(),

since this a https request, I added this code which I though was required
before I could make https call. Not sure here.  There could be certificate
issues here. I would like igonre certificate requests for https calls. I
have done this in Java not sure in Erlang

I would greatly appreciate you help. thx.




--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/custom-plugin-debugging-tp23233p23248.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list