integrate PHP with Erlang

Home Forums Basic Erlang integrate PHP with Erlang

This topic contains 2 replies, has 3 voices, and was last updated by  pzel 5 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #46064

    Aliraza149
    Member

    Hi Everyone, thank you for this opportunity and help. I’m a newbie in Erlang. We have a single sign on written in Php and we need to integrate it with Erlang. Is there any documentation for this, ever done something like this? thx

    _________________
    ali

    • This topic was modified 5 months, 3 weeks ago by  Aliraza149.
    • This topic was modified 5 months, 3 weeks ago by  admin.
    #46086

    zxq9
    Member

    @Aliraza149 Try starting a new thread. You posted this at the bottom of a totally different discussion.

    #46127

    pzel
    Member

    @Aliraza149, you will want to write a ejabberd_auth_yourmodule.erl module that implements the ejabberd_auth callbacks. Inside this module, you can perform your required business logic.

    So, for example, you can have the following workflow:

    * Client logs in via HTTP call to your backend, gets AUTH-TOKEN
    * Client logs in to MongooseIM with ClientID, AUTH-TOKEN as the password
    * ejabberd_auth_yourmodule:check_password/3 gets called with ClientID, XMPPDomain, AUTH-TOKEN
    * ejabberd_auth_yourmodule calls your PHP backend and verifies that the AUTH-TOKEN is valid
    * check_password returns true if valid, false if invalid.

    This module is a very featureful implementation of a scenario like the one above. You don’t have to implement all the functions. The most basic implementation would require check_password/3 to work and all the other functions to return some sane defaults, like the ones below:

    
    %%% ----------------------------------------------------------------------------
    %%% ejabberd_auth API
    %%% ----------------------------------------------------------------------------
    -spec check_password(binary(), binary(), binary()) -> true | false.
    check_password(User, Server, Token) ->
      %% perform your backend calls here
      true.
    
    plain_password_required() ->
        true.
    
    store_type() ->
        plain.
    
    set_password(_User, _Server, _Password) ->
        ok.
    
    try_register(_User, _Server, _Password) ->
        {aborted, unsupported_op}.
    
    dirty_get_registered_users() ->
        [].
    
    get_vh_registered_users(_Server) ->
        [].
    
    get_vh_registered_users(Server, _) ->
        get_vh_registered_users(Server).
    
    get_vh_registered_users_number(_Server) ->
        0.
    
    get_vh_registered_users_number(Server, _) ->
        get_vh_registered_users_number(Server).
    
    get_password(_User, _Server) ->
        false.
    
    get_password_s(_User, _Server) ->
        [].
    
    is_user_exists(_User, _Server) ->
        %% Just assume every user is legal for starters
        true.
    
    remove_user(_User, _Server) ->
        ok.
    
    remove_user(_User, _Server, _Password) ->
        ok.
    
    • This reply was modified 5 months, 3 weeks ago by  pzel.
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.