部署OAuth2.0授权系统时是否需要身份验证?(Is authentication necessary when deploying an OAuth2.0 authorization system?)
在OAuth官方网站上已明确提到,OAuth是一种授权协议,而不是,不应被视为身份验证协议。 在这里我对此感到困惑,OAuth如果首先不对用户进行身份验证,他们如何授权用户。
另一个问题是:我正在设计API以为用户提供Web服务。 如果我使用OAuth2.0,我是否需要登录系统? 如果是这样,如何构建此登录系统?
It's been clearly mentioned in the OAuth official website that the OAuth is an authorization protocol instead of, and should not be considered as an authentication protocol. Here I'm confused about this, how can OAuth authorize users if it doesn't authenticate them in the first place.
Another question is: I'm desiging APIs to provide web services for users. If I use OAuth2.0, do I need a login system? If so, how to build this login system?
原文:https://stackoverflow.com/questions/39484157
最满意答案
new
隐藏了旧方法,这意味着如果您直接在ConvertibleCar
实例上调用它,您将获得派生类的行为,但不会以多态方式调用。当基类调用它时,它调用虚方法,因为它没有被覆盖,所以调用基类方法。 而不是使用方法隐藏(你几乎从不使用方法),只需重写它:
class ConvertibleCar : Car { public override void ShowDetails() { System.Console.WriteLine("A roof that opens up."); } }
new
hides the old method, which means that if you directly call it on aConvertibleCar
instance, you will get the derived class behavior, but it won't be called polymorphically.When the base class calls it, it is calling the virtual method, which since it hasn't been overridden invokes the base class method. Instead of using method hiding (which you almost never use anyways), just override it:
class ConvertibleCar : Car { public override void ShowDetails() { System.Console.WriteLine("A roof that opens up."); } }
相关问答
更多-
使用这个ReflectionClass::getFileName将会得到Child定义的类的dirname。 $reflector = new ReflectionClass("Child"); $fn = $reflector->getFileName(); return dirname($fn); 你可以用get_class()获得一个对象的类名:) Using ReflectionClass::getFileName with this will get you the dirname the cl ...
-
受欢迎的请求.. 尝试一种扩展方法: public T Clone
(this T obj) where T : DBEntityBase { return /* insert code that creates clone here */ } 我必须诚实地说,我认为这不会起作用,因为我预计C#将无法确切地确定它是什么的扩展。 显然然而,它的确如此! By popular request.. Try an extension method: public T Clone (this T obj ... -
没有“基类对象”。 synchronized方法锁定它们被调用的实例。 There is no "base class object". synchronized methods lock on the instance they're called on.
-
基类设置为派生类,不能在派生类中调用方法?(Base class set to derived class, can't call a method in derived class?)[2022-04-28]
键入为基类的变量不能设定有关子类的方法。 例如,对于所有编译器都知道, baseInstance可以保存对Base的引用,或者对SomeOtherClass extends Base 。 现在,你可以说在这种情况下编译器可以解决它,但是:这不是编译器的作用 。 编译器的规则很简单:如果你有一个类型为Base的变量,你只能使用Base已知的东西。 如果你想使用特定子类的专门方法,那么你需要让编译器执行带有类型检查的强制转换,即 Derived special = (Derived)baseInstance; ... -
正如我所看到的,您可以通过继承机制访问受保护的成员,但您仍然无法通过实例访问受保护的成员。 根据MSDN, protected关键字意味着以下内容: protected - 访问限于从包含类 派生的包含类或类型 。 现在,让我们假设编译器让你编译它,现在你迭代你的集合并调用.ToText()方法。 如果node是一个HtmlNode或它的子类,那么你可以调用这个方法。 但是,如果node是某种类型AnotherNode : public class AnotherNode : Node { prot ...
-
Inherited方法无法访问派生类中的新实现(Inherited method has no access to new implementation in derived class)[2023-02-09]
new 隐藏了旧方法,这意味着如果您直接在ConvertibleCar实例上调用它,您将获得派生类的行为,但不会以多态方式调用。 当基类调用它时,它调用虚方法,因为它没有被覆盖,所以调用基类方法。 而不是使用方法隐藏(你几乎从不使用方法),只需重写它: class ConvertibleCar : Car { public override void ShowDetails() { System.Console.WriteLine("A roof that opens up. ... -
由于setReceiveTime()所有成员都protected ,因此您可以在MessageUpdate中使setReceiveTime() private ,因此从MessageUpdate继承的类将无法访问它。 但我的设计仍然存在一些问题,例如: 你的设计如何避免钻石? 它不会同样导致: class MessageWrite {...}; class MessageUpdate: public MessageWrite {...}; //Now, while extending: class Adm ...
-
从基类访问应用于派生类中的方法的属性(Accessing attributes applied to method in derived class from base class)[2022-07-02]
您明确反映了Base类的GetAttributes方法。 更改实现以使用GetType() 。 如: public virtual void GetAttributes() { MethodInfo method = GetType().GetMethod("GetAttributes"); // ... You're explicitly reflecting the Base class's GetAttributes method. Change the implementation ... -
我会这样做:向您的基类添加一个抽象方法: protected abstract Object getArgument(int ordem); 您仍然必须在每个继承类中实现它,但您可以概括比较逻辑。 您的示例的实现将如下所示: protected abstract Object getArgument(int ordem) { switch(ordem) { case 1: return login; case 2: return senha; case 3: ret ...
-
您可以将Foo方法声明设为受保护的内部.... public class BaseClass { protected internal virtual void Foo(){} } public class Derived1 : BaseClass { protected internal override void Foo() { //some code... } } 这里的“protected internal”意味着该成员对继承基类的任何类都是可见的,无论它是 ...