在apex中基于2种不同类型的用户进行自定义身份验证 [英] Making a custom authentication based on 2 different types of users in apex

查看:133
本文介绍了在apex中基于2种不同类型的用户进行自定义身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个身份验证方案,该身份验证方案目前仅验证用户是否在一个表(即雇主"表)中.现在,我希望此身份验证方案可以验证用户是雇主还是雇员,并基于他们是雇主还是雇员,应将其重定向到其他页面.

I have an authentication scheme that currently only verifies whether the user is in one table, namely the employer table. Now I want this authentication scheme to verify whether the user is an employer OR a employee, and based on whether they are an employer or employee it should redirect them to different pages.

首先,我将如何在身份验证脚本中包含第二个表?我最大的问题是,当员工登录时,我需要第二个应用程序链接到第一个应用程序吗?还可以怎么做?目前,我只有雇主登录时使用的雇主论坛和页面.如果员工登录,我将如何隐藏所有雇主报告/表格,只让他们看到员工表格/报告?

First of all how would I include a second table in the authentication script? And my biggest problem is would I need a second application that links to the first application for when an employee logs in? How else could this be done? I currently only have employer forums and pages for when an employer logs in. If an employee logs in how would I hide all the employer reports/forms and only let them see employee forms/reports?

我当前的身份验证方案如下所示.

My current authentication scheme is shown below.

FUNCTION authenticate(p_username IN VARCHAR2
  ,p_password IN VARCHAR2) RETURN BOOLEAN IS
   l_value       NUMBER;
   l_returnvalue BOOLEAN;
 BEGIN
   BEGIN
     SELECT 1
       INTO l_value
       FROM employer
      WHERE 1 = 1
        AND upper(employer.username) = upper(p_username)
        AND upper(employer.passwords) = upper(p_password);
   EXCEPTION
     WHEN no_data_found
          OR too_many_rows THEN
       l_value := 0;
     WHEN OTHERS THEN
       l_value := 0;
   END;
   l_returnvalue := l_value = 1;
   RETURN l_returnvalue;
 END;     

推荐答案

这是授权方案"问题,而不是验证方案"问题.

This is an 'Authorisation Scheme' problem, not a 'Authentication Scheme' issue.

身份验证方案是应用程序的关守.如果允许用户进入,请然后考虑他们是哪种类型的用户.

The authentication scheme is the gatekeeper to your application. If the user is allowed in, then consider what type of user they are.

您可以使用授权方案"来执行此操作,这取决于您将其标识为雇主还是雇员的方式得出对/错.然后,您可以将这些授权方案与应用程序中的各个组件相关联-页面,菜单项/链接,报告,按钮,..分支-您可以在应用程序的主页上定义它们.

You can use 'Authorisation Schemes' to do this, deriving true/false depending on how you identify them as employer or employee. You can then associate these authorisation schemes to various components in your application - page, menu items/links, reports, buttons, .. branches - which you could define on the home page of your application.

例如:如果用户具有授权方案x,则将其发送至第2页,否则将其发送至第3页.

eg: If the user has authorisation scheme x, then send then to page 2, else send them to page 3.

但是,如果您希望扩展此概念,建议您为功能定义授权方案,然后通过自定义表将这些功能分配给业务角色.然后,可以将业务角色(员工,雇主)与特定的:APP_USER相关联.

But if you want this concept to scale, I recommend defining authorisation schemes for features, then allocate those features to business roles, via your custom tables. Then business roles (employees, employers) can be associated to specific :APP_USER.

您的示例代码还建议您使用商店明文密码. 不要这样做.甚至没有例子.哈希密码应该是默认设置-Dimitri Gielis很好地说明了如何设置自定义身份验证此处.

Your sample code also suggest your store clear text passwords. Don't do that. Not even for examples. Hashing passwords should be a default thing - Dimitri Gielis has a good example of how to set up custom authentication here.

和/或查看属性帮助中的示例:

And/or review the example in the attribute help:

这篇关于在apex中基于2种不同类型的用户进行自定义身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆