Link to home
Start Free TrialLog in
Avatar of Pete2003
Pete2003

asked on

APEX Own Login Function

Hi All,

I have written my own login procedure which replaces wwv_flow_custom_auth_std.login. The short reason is that I'm using my own authentication tables and methods.

Now what I have done that when the function returns it brings back an error code. 0 is no error or some other number for error.

My problem is now how to make apex accept my authentication as succesfull. Whatever I do I always get sent back to the login page.

I have tried the following:
- I have created hidden fields on the page and stored the error code, then on a newly created branch, I test the error code and branch to the approppriate page. I have now set the branch to always return 2 which means that it should always go to page 2 (to avoid any errors here). Thsi still sends me back to login.
- I have tried changing the authentication schemas authentication function and I am using my own function which also always returns true. This still does not work.

How can I tell APEX that I have authenticated my application/user?

Thanks



Avatar of gatorvip
gatorvip
Flag of United States of America image

It sounds like you didn't designate your authentication scheme as default. Go to the application interface, then under Shared Components, click on Authentication Schemes.

Click Create, then go through the prompts. You can leave most fields blank for now, the only one that's necessary is the Authentication Function field, where you should have something like

return <your_authentication_function>; (which accepts two parameters, username and password).

Then you also need to have the following, somewhere in the login process. For example, you could put it on your login page (usually 101), as an After Submit process:

    wwv_flow_custom_auth_std.login(
        P_UNAME       => :P101_USERNAME,
        P_PASSWORD    => :P101_PASSWORD,
        P_SESSION_ID  => v('APP_SESSION'),
        P_FLOW_PAGE   => :APP_ID||':1'
    );
Sorry, forgot one step. Once the authentication scheme is created, you need to click on the Change Current link (under Tasks, on the right hand side) then select your scheme.
Avatar of Pete2003
Pete2003

ASKER

Hi, Thanks for the answer.

Two Issues however:
1) I don't want to tun the wwv_flow_custom_auth_std.login as already part of my process-login I have removed that function and put it my own function there. This is because my login function doesn't just return a true or false it returns some data as OUT parameters.
A simpliefied example of what I mean:
DECLARE
 P_MESSAGE  VARCHAR2(200);
BEGIN
 MY_LOGIN_USER(:P101_USERNAME, :P101_PASSWORD, P_MESSAGE);
 :P2_MESSAGE := P_MESSAGE;
END;

2) Having an issue running the function authentication function you suggested:
ORA-01008: not all variables bound
ERR-10460 Unable to run authentication credential check function.

The function I put in is:
return my_auth(:P101_USERNAME, :P101_PASSWORD);


Thanks
Back. False alarm, was sorted as I was supposed to use
return my_auth;
instead of
return my_auth(:P101_USERNAME, :P101_PASSWORD);

So the error is gone but now I still get stuck on login page.
If I try and replace my function with the standard wwv_flow_custom_auth_std.login the login works but obviously my out parameters don't get populated.

Thanks
ALso to emphesize the need for my own login function. I want that function to also set some session parameters which can then be used through the application.

Thanks
>>This is because my login function doesn't just return a true or false it returns some data as OUT parameters.
>>I want that function to also set some session parameters which can then be used through the application.

OK, I understand. The issue is that neither one is directly related to authentication. Because you have to register your function to operate within the APEX engine, you are limited to the following signature:

http://download.oracle.com/docs/cd/E14373_01/apirefs.32/e13369/apex_auth.htm#BABGGHII

APEX_CUSTOM_AUTH.LOGIN(
    p_uname                    IN  VARCHAR2  DEFAULT NULL,
    p_password                 IN  VARCHAR2  DEFAULT NULL,
    p_session_id               IN  VARCHAR2  DEFAULT NULL,
    p_app_page                 IN  VARCHAR2  DEFAULT NULL,
    p_entry_point              IN  VARCHAR2  DEFAULT NULL,
    p_preserve_case            IN  BOOLEAN   DEFAULT FALSE);

(and p_entry_point is for internal use only).

What you need to do then is use application items that are set in either of two points:
a) as part of the Post-Authentication Process available on the Authentication scheme page, which runs right after the actual authentication process and before the next page is loaded
b) as an application process with the Process Point set to On New Session: After Authentication

In either case, when the process runs, you know that your user is valid and authenticated, so you can call a function that takes the username as an input parameter.
I almost understand :)

So you are telling me the two options of when to set my 'message', etc items? Is that correct ? If that is so, does that mean that I shoudl totally forgo my own authentication function, use the standard 'wwv_flow_custom_auth_std.login' in conjunction with my newly creaed authentication theme and then in my 'After Authentication' I can set my parameters?

Two questions then again:
1) In the 'After Authentication' I would need to run another stored procedure (with the assumption that we have authenticated) and load all my data into variables which would have been loaded in my original method?
2) I'm not sure this answers my login page question. In the case of my authentication function returning true or false, I keep getting sent back to the login page still.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of gatorvip
gatorvip
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

Ok I'm all sorted .. my biggest issue was that I thought that 'wwv_flow_custom_auth_std.login' was an actual login (silly me making assumptions form names :) ). Now I see that my function logs in and this function just sets up the session.

With that cleared up it's all working 100%

Thanks a ton for all your help.