You are not logged in.
Pages: 1
I'm trying to implement simple authentication based on username and password:
TMyAuthenticator = class(TRestServerAuthenticationNone)
protected
function Auth(Ctxt: TRestServerUriContext): boolean; override;
end;
Server.AuthenticationRegister(TMyAuthenticator);
function TMyAuthenticator.Auth(Ctxt: TSQLRestServerURIContext): boolean;
begin
Result := True;
end;
but the url http://localhost/auth?UserName=xxx&Password=yyy displays an error:
{
"errorCode":400,
"errorText":"Bad Request"
}
How to get the UserName and Password from Ctxt?
Offline
It does not help:
TMyAuthenticator = class(TRestServerAuthenticationUri)
protected
function Auth(Ctxt: TRestServerUriContext): boolean; override;
end;
function TMyAuthenticator.Auth(Ctxt: TSQLRestServerURIContext): boolean;
begin
Result := Ctxt.InputUtf8['UserName']<>'xyz' // -> TRUE under debug
end;
what I am doing wrong?
Offline
I've added:
function TMyAuthenticator.Auth(Ctxt: TSQLRestServerURIContext): boolean;
begin
Result := True;
var body: TDocVariantData;
body.InitFast(10,dvObject);
Ctxt.ReturnsJson(variant(body));
end;
I'm not sure if self-made response like that is a good practice.
Offline
Pages: 1