In trying to implement authentication in CKFinder by following this "howto", I've written the following file, saved to my CKFinder directory:
<%@page codepage="65001" language="C#" lcid="6153"%>
<%
using CKSource.CKFinder.Connector.Core;
using CKSource.CKFinder.Connector.Core.Authentication;
public class MyAuthenticator:IAuthenticator{
public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
return Task.FromResult((IUser)new User(true,"editor"));
}
}
%>
However, when I try to load it, I get the a compiler error (CS1513
) on the line containing the second using
statement stating that a closing bracket (}
) is expected, despite the fact that there is no opening bracket ({
) anywhere in the file before that line.
Given that I have next to no knowledge of ASP.NET, can someone shed some light on what's happening here and how I would go about solving it?
I have, despite knowing it wouldn't work, tried adding a }
to the end of that line to see what would happen and it throws a different compiler error - "CS1518
: Expected class, delegate, enum, interface, or struct" - in a completely different file "App_Web_auth.aspx.*.*.0.cs" (the asterisks being random strings of characters on each reload) which, strangely, is nested a few directories down in my %WINDIR%
. That error occurs on line 214, which is the second line in the following extract:
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
protected override void FrameworkInitialize() {
base.FrameworkInitialize();
this.@__BuildControlTree(this);
this.AddWrappedFileDependencies(global::ASP.auth_aspx.@__fileDependencies);
this.Request.ValidateInput();
}
UPDATE 1
If I remove the public class completely, I get yet another compiler error - "CS1003:
Syntax error, '(' expected" - this time on the line containing the first using
statement. Trial and error led me to figure out that the using
statements need to be enclosed in parnetheses but, after adding the public class back in, I still get the original error about the missing }
.
<%@page codepage="65001" language="C#" lcid="6153"%>
<%
using(CKSource.CKFinder.Connector.Core);
using(CKSource.CKFinder.Connector.Core.Authentication);
public class MyAuthenticator:IAuthenticator{
public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
return Task.FromResult((IUser)new User(true,"editor"));
}
}
%>
Removing the class again leads to another new error - "CS0119
: 'CKSource.CKFinder.Connector.Core' is a 'namespace', which is not valid in the given context"
UPDATE 2
Per SeM's suggestion, I added the following to the system.web
section of CKF's "Web.config" file:
<pages>
<namespaces>
<add namespace="CKSource.CKFinder.Connector.Core" />
<add namespace="CKSource.CKFinder.Connector.Core.Authentication" />
</namespaces>
</pages>
And updated the contents of my file to be:
<%@page codepage="65001" language="C#" lcid="6153"%>
<%@import namespace="ConnectorBuilder.SetAuthenticator"%>
<%
public class MyAuthenticator:IAuthenticator{
public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
return Task.FromResult((IUser)new User(true,"editor"));
}
}
%>
This, however, leads to the original error ("CS1513
: } expected") now being thrown on line 214 (first line in below extract) of that mystery file in my %WINDIR%
- with the added weirdness of the contents of that file having somehow changed.
private void @__Render__control1(System.Web.UI.HtmlTextWriter @__w, System.Web.UI.Control parameterContainer) {
#line 3 "x:\redacted\path\to\myfile.aspx"
public class MyAuthenticator:IAuthenticator{
public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
return Task.FromResult((IUser)new User(true,"editor"));
}
}
#line default
#line hidden
}
UPDATE 3
Changing my file to use a script
tag:
<%@page codepage="65001" language="c#" lcid="6153"%>
<%@import namespace="ConnectorBuilder.SetAuthenticator"%>
<script language="c#" runat="server">
public class MyAuthenticator:IAuthenticator{
public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
return Task.FromResult((IUser)new User(true,"editor"));
}
}
</script>
Leads to a brand new error on line 2: "CS0246
: The type or namespace name 'ConnectorBuilder' could not be found (are you missing a using directive or an assembly reference?)"
UPDATE 4
I removed the import
directive and received the following error on the line declaring the public task: "CS0246
: The type or namespace name 'CancellationToken' could not be found (are you missing a using directive or an assembly reference?)".