AngularJS and Spring Security. How to handle AngularJS Urls with Spring Security -
let me explain problem. have implemented site in angularjs accessed this:
http://localhost:8080/example/resources/#/
here can call different pages, example login page:
http://localhost:8080/example/resources/#/login
admin page:
http://localhost:8080/example/resources/#/admin
user page:
http://localhost:8080/example/resources/#/user
now, have implemented spring security in example in order catch every call , check if has role_user privileges. far good, have done configuration in spring security context file:
<security:http create-session="stateless" entry-point-ref="restauthenticationentrypoint" authentication-manager-ref="authenticationmanager"> <security:custom-filter ref="customrestfilter" position="basic_auth_filter" /> <security:intercept-url pattern="/**" access="role_user" /> </security:http>
this configuration checks every url called, if user has proper roles, , works fine, throws 401 unauthorized page.
the problem i`m having when put login page accessed i'll way:
<security:http create-session="stateless" entry-point-ref="restauthenticationentrypoint" authentication-manager-ref="authenticationmanager"> <security:custom-filter ref="customrestfilter" position="basic_auth_filter" /> <security:intercept-url pattern="/login**" access="role_anonymous" /> <security:intercept-url pattern="/**" access="role_user" /> </security:http>
but dont know why spring security not catching url. maybe angular manages url differently.
finally have tried deleting <security:intercept-url pattern="/**" access="role_user" />
, giving /login** access role_user only, page not found. know happening here?
thanks in advance!!!
i wrote little sample application illustrates how integrate angularjs spring security exposing session id http header (x-auth-token). sample provides (simple) authorization (returning roles server) client angularjs application can react that. of course user-experience (ux) purposes. make sure rest endpoints have property security.
my blog post on here.
Comments
Post a Comment