Authentication in Scout 8 [message #1797704] |
Mon, 05 November 2018 12:56 |
|
Hello,
I need help how to implement an authentication regarding a database table in scout 8, I created a table User and now I would like to enable authentication of users regarding to theire login and password stored in the table.
Kind Regards
Anis
|
|
|
Re: Authentication in Scout 8 [message #1797774 is a reply to message #1797704] |
Tue, 06 November 2018 10:01 |
|
Hello,
I succeeded implementing an authentication using this thread
https://stackoverflow.com/questions/40914718/eclipse-scout-clean-database-authentication
But I have an error showing up after login :
java.io.IOException: Failed running org.eclipse.scout.rt.ui.html.scriptprocessor.internal.impl.MinifyJsWithYui
at org.eclipse.scout.rt.ui.html.scriptprocessor.ScriptProcessor.runInClassLoader(ScriptProcessor.java:97)
at org.eclipse.scout.rt.ui.html.scriptprocessor.ScriptProcessor.minifyJs(ScriptProcessor.java:77)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.minifyContent(ScriptFileBuilder.java:346)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.compileAndMinifyContent(ScriptFileBuilder.java:327)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.processMacroWithIncludesRec(ScriptFileBuilder.java:249)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.buildScript(ScriptFileBuilder.java:117)
at org.eclipse.scout.rt.ui.html.res.loader.ScriptFileLoader.loadResource(ScriptFileLoader.java:59)
at org.eclipse.scout.rt.ui.html.res.loader.AbstractResourceLoader.loadResource(AbstractResourceLoader.java:45)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.getScriptAndFingerprint(HtmlDocumentParser.java:167)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.createExternalPath(HtmlDocumentParser.java:111)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.replaceScriptTags(HtmlDocumentParser.java:93)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.replaceScriptTags(HtmlDocumentParser.java:212)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.replaceAllTags(HtmlDocumentParser.java:81)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.parseDocument(HtmlDocumentParser.java:71)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlFileLoader.loadResource(HtmlFileLoader.java:103)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlFileLoader.loadResource(HtmlFileLoader.java:70)
at org.eclipse.scout.rt.ui.html.res.ResourceRequestHandler.resolveResourceFromCache(ResourceRequestHandler.java:124)
at org.eclipse.scout.rt.ui.html.res.ResourceRequestHandler.handleGet(ResourceRequestHandler.java:78)
at org.eclipse.scout.rt.ui.html.AbstractUiServletRequestHandler.handle(AbstractUiServletRequestHandler.java:26)
at org.eclipse.scout.rt.ui.html.UiServlet.handleRequestInternal(UiServlet.java:255)
at org.eclipse.scout.rt.ui.html.UiServlet.lambda$0(UiServlet.java:219)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequiresNew(TransactionProcessor.java:100)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequired(TransactionProcessor.java:129)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.intercept(TransactionProcessor.java:71)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:156)
at org.eclipse.scout.rt.ui.html.UiServlet.handleRequest(UiServlet.java:219)
at org.eclipse.scout.rt.ui.html.UiServlet.doGet(UiServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.access$0(AbstractHttpServlet.java:1)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.wrap(AbstractHttpServlet.java:49)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.service(AbstractHttpServlet.java:38)
at org.eclipse.scout.rt.ui.html.UiServlet.service(UiServlet.java:141)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634)
at org.eclipse.scout.rt.server.commons.servlet.filter.gzip.GzipServletFilter.doFilter(GzipServletFilter.java:84)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1621)
at org.eclipse.scout.rt.server.commons.authentication.ServletFilterHelper.lambda$0(ServletFilterHelper.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.eclipse.scout.rt.server.commons.authentication.ServletFilterHelper.continueChainAsSubject(ServletFilterHelper.java:155)
at org.eclipse.scout.rt.server.commons.authentication.TrivialAccessController.handleRequest(TrivialAccessController.java:103)
at org.eclipse.scout.rt.server.commons.authentication.TrivialAccessController.handle(TrivialAccessController.java:78)
I do not know how to deal with it, can any one help ?
|
|
|
|
Re: Authentication in Scout 8 [message #1797789 is a reply to message #1797777] |
Tue, 06 November 2018 12:35 |
|
Hello,
this is the hole error stuck,
MinifyJsWithYui error: missing name after . operator
MinifyJsWithYui error: invalid property id
MinifyJsWithYui error: missing ; before statement
MinifyJsWithYui error: missing name after . operator
MinifyJsWithYui error: missing name after . operator
MinifyJsWithYui error: missing name after . operator
MinifyJsWithYui error: invalid property id
MinifyJsWithYui error: Compilation produced 7 syntax errors.
2018-11-06 13:32:51,238 ERROR [qtp929383713-20] org.eclipse.scout.rt.ui.html.UiServlet.handleRequestInternal(UiServlet.java:262) - Exception while processing request - MDC[principal=admin, cid=9be92fc2-5e86-47d8-9d33-4da5f510630f]
java.io.IOException: Failed running org.eclipse.scout.rt.ui.html.scriptprocessor.internal.impl.MinifyJsWithYui
at org.eclipse.scout.rt.ui.html.scriptprocessor.ScriptProcessor.runInClassLoader(ScriptProcessor.java:97)
at org.eclipse.scout.rt.ui.html.scriptprocessor.ScriptProcessor.minifyJs(ScriptProcessor.java:77)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.minifyContent(ScriptFileBuilder.java:346)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.compileAndMinifyContent(ScriptFileBuilder.java:327)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.processMacroWithIncludesRec(ScriptFileBuilder.java:249)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.buildScript(ScriptFileBuilder.java:117)
at org.eclipse.scout.rt.ui.html.res.loader.ScriptFileLoader.loadResource(ScriptFileLoader.java:59)
at org.eclipse.scout.rt.ui.html.res.loader.AbstractResourceLoader.loadResource(AbstractResourceLoader.java:45)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.getScriptAndFingerprint(HtmlDocumentParser.java:167)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.createExternalPath(HtmlDocumentParser.java:111)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.replaceScriptTags(HtmlDocumentParser.java:93)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.replaceScriptTags(HtmlDocumentParser.java:212)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.replaceAllTags(HtmlDocumentParser.java:81)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlDocumentParser.parseDocument(HtmlDocumentParser.java:71)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlFileLoader.loadResource(HtmlFileLoader.java:103)
at org.eclipse.scout.rt.ui.html.res.loader.HtmlFileLoader.loadResource(HtmlFileLoader.java:70)
at org.eclipse.scout.rt.ui.html.res.ResourceRequestHandler.resolveResourceFromCache(ResourceRequestHandler.java:124)
at org.eclipse.scout.rt.ui.html.res.ResourceRequestHandler.handleGet(ResourceRequestHandler.java:78)
at org.eclipse.scout.rt.ui.html.AbstractUiServletRequestHandler.handle(AbstractUiServletRequestHandler.java:26)
at org.eclipse.scout.rt.ui.html.UiServlet.handleRequestInternal(UiServlet.java:255)
at org.eclipse.scout.rt.ui.html.UiServlet.lambda$0(UiServlet.java:219)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequiresNew(TransactionProcessor.java:100)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequired(TransactionProcessor.java:129)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.intercept(TransactionProcessor.java:71)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:156)
at org.eclipse.scout.rt.ui.html.UiServlet.handleRequest(UiServlet.java:219)
at org.eclipse.scout.rt.ui.html.UiServlet.doGet(UiServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.access$0(AbstractHttpServlet.java:1)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.wrap(AbstractHttpServlet.java:49)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.service(AbstractHttpServlet.java:38)
at org.eclipse.scout.rt.ui.html.UiServlet.service(UiServlet.java:141)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634)
at org.eclipse.scout.rt.server.commons.servlet.filter.gzip.GzipServletFilter.doFilter(GzipServletFilter.java:84)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1621)
at org.eclipse.scout.rt.server.commons.authentication.ServletFilterHelper.lambda$0(ServletFilterHelper.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.eclipse.scout.rt.server.commons.authentication.ServletFilterHelper.continueChainAsSubject(ServletFilterHelper.java:155)
at org.eclipse.scout.rt.server.commons.authentication.TrivialAccessController.handleRequest(TrivialAccessController.java:103)
at org.eclipse.scout.rt.server.commons.authentication.TrivialAccessController.handle(TrivialAccessController.java:78)
at com.anis.recovery.app.recovery.ui.html.UiServletFilter.doFilter(UiServletFilter.java:52)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1613)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:541)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1593)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1239)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:481)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1562)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1141)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.scout.rt.ui.html.scriptprocessor.ScriptProcessor.runInClassLoader(ScriptProcessor.java:89)
... 71 common frames omitted
Caused by: java.lang.NullPointerException: null
at org.mozilla.javascript.Parser.parse(Parser.java:396)
at org.mozilla.javascript.Parser.parse(Parser.java:340)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:314)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:539)
at org.eclipse.scout.rt.ui.html.scriptprocessor.internal.impl.MinifyJsWithYui.run(MinifyJsWithYui.java:52)
... 76 common frames omitted
I changed the UiSerfletFilter to implement database authentication process throw a service that compare the user and login and see if they exist in the database.
what is the
MinifyJsWithYui error: missing name after . operator
MinifyJsWithYui error: invalid property id
MinifyJsWithYui error: missing ; before statement
MinifyJsWithYui error: missing name after . operator
MinifyJsWithYui error: missing name after . operator
MinifyJsWithYui error: missing name after . operator
MinifyJsWithYui error: invalid property id
MinifyJsWithYui error: Compilation produced 7 syntax errors.
?
|
|
|
|
Re: Authentication in Scout 8 [message #1797803 is a reply to message #1797793] |
Tue, 06 November 2018 14:52 |
|
Hello,
I did not changed any javascript, this what I done,
I wanted to implement a database authentication
you know that eclipse scout project are automaticly created against the config.ini file authentication, this is implemented in the UiServletFilter class
@Override
public void init(FilterConfig filterConfig) throws ServletException {
m_trivialAccessController = BEANS.get(TrivialAccessController.class).init(new TrivialAuthConfig()
.withExclusionFilter(filterConfig.getInitParameter("filter-exclude")).withLoginPageInstalled(true));
m_formBasedAccessController = BEANS.get(FormBasedAccessController.class)
.init(new FormBasedAuthConfig().withCredentialVerifier(BEANS.get(ConfigFileCredentialVerifier.class)));
m_developmentAccessController = BEANS.get(DevelopmentAccessController.class).init();
}
I changed it to :
@Override
public void init(FilterConfig filterConfig) throws ServletException {
m_trivialAccessController = BEANS.get(TrivialAccessController.class).init(new TrivialAuthConfig()
.withExclusionFilter(filterConfig.getInitParameter("filter-exclude")).withLoginPageInstalled(true));
m_formBasedAccessController = BEANS.get(FormBasedAccessController.class)
.init(new FormBasedAuthConfig().withCredentialVerifier(BEANS.get(DataSourceCredentialVerifier.class)));
m_developmentAccessController = BEANS.get(DevelopmentAccessController.class).init();
}
This class contain a methode named verify
@Override
public int verify(String username, char[] password) throws IOException {
Subject subject = new Subject();
subject.getPrincipals().add(new SimplePrincipal("system"));
subject.setReadOnly();
RunContext runContext = RunContexts.empty();
Object[][] result = runContext.call(new Callable<Object[][]>() {
@Override
public Object[][] call() throws Exception {
return BEANS.get(IDBAuthService.class).load(username, password);
}
});
if (result.length > 0)
return AUTH_OK;
else
return AUTH_FAILED;
}
that uses a service IDBAuthenService that will perform a query in the database base on the login and password provided in the login form,
the login is correct , I mean it return AUTH_OK then it runs in the previously mentioned error.
and even when using the ConfigFileCredentialVerifier I have the same error !!
So I am missing a peace in the implementation of the authentication ;..
|
|
|
|
Re: Authentication in Scout 8 [message #1798106 is a reply to message #1797809] |
Mon, 12 November 2018 15:10 |
|
Hello,
I found out the problem it was related to the js used for the chats component, when I removed them I was I able to make the authentication to the DB, I do not know what is the relation between them but I am analyzing it deeper.
Kind Regards
|
|
|
Re: Authentication in Scout 8 [message #1805911 is a reply to message #1798106] |
Sat, 27 April 2019 18:34 |
Krzysztof Leja Messages: 55 Registered: April 2019 |
Member |
|
|
Hi,
I have the same case as in this thread: I would like to implement the authentication of users logging in to my application (using the Scout 9 version), with the participation of a dedicated table in the database.
Using all the tips given here, I made the following changes:
1. In the "shared" module I added a new authorization interface, as follows:
@TunnelToServer
public interface ISqlAuthService {
public int verify(String username, char[] password);
}
2. In the "server" module, I added the implementation of this interface, which verifies the user in the database.
3. In the "client" module I added the implementation of the ICredentialVerifier interface, which calls the above-mentioned service, as follows:
public class DataSourceCredentialVerifier implements ICredentialVerifier {
@Override
public int verify(String username, char[] password) throws IOException {
Subject subject = new Subject();
subject.getPrincipals().add(new SimplePrincipal("system"));
subject.setReadOnly();
RunContext runContext = RunContexts.empty();
return runContext.call(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return BEANS.get(ISqlAuthService.class).verify(username, password);
}
});
}
}
4. In the "ui.html" module in the existing UiServletFilter class I have added a reference to the above mentioned DataSourceCredentialVerifier.
When I run my application in development mode (ie through modules * .app.dev) and then submit login form, I get this exception:
Quote:
org.eclipse.scout.rt.platform.exception.ExceptionHandler.handleThrowable(ExceptionHandler.java:135) - SecurityException:service registry does not contain a service of type pl.myapps.helloword.shared.security.ISqlAuthService - MDC[principal=KL, cid=937b2ab9-76bb-4751-8b4c-0907daec1b39]
java.lang.SecurityException: service registry does not contain a service of type pl.myapps.helloword.shared.security.ISqlAuthService
What else do I need to do to make it work?
[Updated on: Sat, 27 April 2019 18:51] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05391 seconds