These are chat archives for spring-guides/tut-spring-security-and-angular-js

2nd
Jul 2015
Karthik
@karthikpamidimarri
Jul 02 2015 14:46
@dsyer Hi, I want to create Authentication Server and multiple resource server using spring boot , I was referring some links but not able to find the correct solution please suggest me some reference how to setup the project structure with spring boot
Dave Syer
@dsyer
Jul 02 2015 15:08
Did you look at the code in this repo?
Karthik
@karthikpamidimarri
Jul 02 2015 15:32
Not at I followed in some other repository
I will check in this repository
LazarN
@LazarN
Jul 02 2015 15:42
@dsyer Hello, I have problem following the tutorial. I described my problem here:
Dave Syer
@dsyer
Jul 02 2015 15:43
Looks like a CORS issue
You need to send the headers. You said you "enabled it in tomcat" but that doesn't mean anything to me.
LazarN
@LazarN
Jul 02 2015 15:44
configured tomcat web.xml
marcelgulbahar
@marcelgulbahar
Jul 02 2015 15:44
this is a really simple way to enable it: https://spring.io/guides/gs/rest-service-cors/
Dave Syer
@dsyer
Jul 02 2015 15:44
I guess that's not doing what you expected it to
N.B. also your csrfTokenRepository() is not being used. So you will have a CSRF problem if you solve this one.
LazarN
@LazarN
Jul 02 2015 15:45
I already did this @adaofeliz but I am not sure if I need to add something else to the web.xml
marcelgulbahar
@marcelgulbahar
Jul 02 2015 15:45
please share a gist with your web.xml
LazarN
@LazarN
Jul 02 2015 15:46

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
<display-name>Archetype Created Web Application</display-name>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/classes/spring.xml</param-value>
</context-param>

<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextClass</param-name>
        <param-value>org.springframework.web.context.support.XmlWebApplicationContext</param-value>
    </init-param>
     <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/classes/spring.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>


<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

</web-app>

marcelgulbahar
@marcelgulbahar
Jul 02 2015 15:48
Hey @LazarN I'm not seeing a CORS filter on it...
LazarN
@LazarN
Jul 02 2015 15:51

yes, as soon as I try to add

  <filter>
<filter-name>simpleCORSFilter</filter-name>
<filter-class>
   com.myapp.config.CorsFilter
</filter-class>

</filter>

<filter-mapping>
<filter-name>simpleCORSFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

the IDE indicates that there is some error
I have no idea why
in the web.xml
marcelgulbahar
@marcelgulbahar
Jul 02 2015 15:53
and which error does the IDE indicates?
LazarN
@LazarN
Jul 02 2015 15:53
The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param,filter,filter-mapping,listener,servlet,servlet-
mapping
,session-config?,mime-mapping,welcome-file-list?,error-page,taglib,resource-env-ref,resource-ref,security-constraint,login-config?,security-role,env-
entry
,ejb-ref,ejb-local-ref)".
marcelgulbahar
@marcelgulbahar
Jul 02 2015 15:56

try adding the filter and the filter-mapping between:
</context-param>
----HERE----

<listener>

LazarN
@LazarN
Jul 02 2015 15:58
yes, it doesn`t give me the error anymore but I still cannot access the resource from another domain
marcelgulbahar
@marcelgulbahar
Jul 02 2015 15:59
ok, time for debug... restart it in debug mode and add a break point in the first line of the filter method
LazarN
@LazarN
Jul 02 2015 16:01
doFilter() ?
it didn`t invoke it :(
yes I am in debug
marcelgulbahar
@marcelgulbahar
Jul 02 2015 16:05
ok send me your filter (please use: https://gist.github.com/)
LazarN
@LazarN
Jul 02 2015 16:05
sent
marcelgulbahar
@marcelgulbahar
Jul 02 2015 16:06
I mean share the gist link :P
sorry
: /
marcelgulbahar
@marcelgulbahar
Jul 02 2015 16:11
You can remove @Component and @Order - Filters from import javax.servlet.Filter are not part of the application context ...
are you importing import javax.servlet.Filter ?
LazarN
@LazarN
Jul 02 2015 16:12
yes I am
exactly the same class is imported
LazarN
@LazarN
Jul 02 2015 16:16
my imports are the same as the link you shared earlier
Thank you very much! I really appreciate it! I will try it and let you know :)
Karthik
@karthikpamidimarri
Jul 02 2015 16:23
@dsyer Hi Dsyer I checked the code and able to run this repo and I have doubt can it's possible to do login and authorize on a single click
Dave Syer
@dsyer
Jul 02 2015 17:34
You need to set up auto approve for the client.
It's part of the config builder api in the Auth server