Ich versuche spring security rest plugin Version 1.4.1 in meiner Grails App zu integrieren, aber einige Frage, die sich, ich bin wie das zu tun:Spring Security Rest Plugin: Authentifizierung fehlgeschlagen, keine AuthenticationProvider
Config.groovy Einstellung :
//login end point
grails.plugin.springsecurity.rest.login.active=true
grails.plugin.springsecurity.rest.login.endpointUrl='/api/login'
grails.plugin.springsecurity.rest.login.failureStatusCode='401'
//for memcached
grails.plugin.springsecurity.rest.token.storage.useMemcached=true
grails.plugin.springsecurity.rest.token.storage.memcached.hosts='localhost:11211'
grails.plugin.springsecurity.rest.token.storage.memcached.username=''
grails.plugin.springsecurity.rest.token.storage.memcached.password=''
grails.plugin.springsecurity.rest.token.storage.memcached.expiration=3600
//logout endpoint
grails.plugin.springsecurity.rest.logout.endpointUrl='/api/logout'
grails.plugin.springsecurity.rest.token.validation.headerName='X-Auth-Token'
//accept request params as map
grails.plugin.springsecurity.rest.login.useRequestParamsCredentials=true
grails.plugin.springsecurity.rest.login.usernamePropertyName='username'
grails.plugin.springsecurity.rest.login.passwordPropertyName='password'
und
grails.plugin.springsecurity.filterChain.chainMap = [
'/api/guest/**': 'anonymousAuthenticationFilter,restExceptionTranslationFilter,filterInvocationInterceptor',
'/api/**': 'JOINED_FILTERS,-exceptionTranslationFilter,-authenticationProcessingFilter,-securityContextPersistenceFilter,-rememberMeAuthenticationFilter', // Stateless chain
'/**': 'JOINED_FILTERS,-restTokenValidationFilter,-restExceptionTranslationFilter' // Traditional chain
]
Wie Sie sehen aus können Einstellung I Memcach bin mit e für Token Lagerung, wenn ich die URL getroffen api/login
über einen Rest Client I 401 bekam aktiviert ich die Protokolle in dem es heißt, dass Authentifizierungsanbieter gefunden ist nicht
Hier werden die Protokolle:
2015-04-03 23:30:31,030 [http-bio-8080-exec-8] DEBUG matcher.AntPathRequestMatcher - Checking match of request : '/api/login'; against '/api/guest/**'
2015-04-03 23:30:31,031 [http-bio-8080-exec-8] DEBUG matcher.AntPathRequestMatcher - Checking match of request : '/api/login'; against '/api/**'
2015-04-03 23:30:31,031 [http-bio-8080-exec-8] DEBUG web.FilterChainProxy - /api/[email protected]&password=test456 at position 1 of 8 in additional filter chain; firing Filter: 'RestLogoutFilter'
2015-04-03 23:30:31,031 [http-bio-8080-exec-8] DEBUG web.FilterChainProxy - /api/[email protected]&password=test456 at position 2 of 8 in additional filter chain; firing Filter: 'MutableLogoutFilter'
2015-04-03 23:30:31,031 [http-bio-8080-exec-8] DEBUG web.FilterChainProxy - /api/[email protected]&password=test456 at position 3 of 8 in additional filter chain; firing Filter: 'RestAuthenticationFilter'
2015-04-03 23:30:31,031 [http-bio-8080-exec-8] DEBUG rest.RestAuthenticationFilter - Actual URI is /api/login; endpoint URL is /api/login
2015-04-03 23:30:31,031 [http-bio-8080-exec-8] DEBUG rest.RestAuthenticationFilter - Applying authentication filter to this request
2015-04-03 23:30:31,031 [http-bio-8080-exec-8] DEBUG credentials.RequestParamsCredentialsExtractor - Extracted credentials from request params. Username: [email protected], password: [PROTECTED]
2015-04-03 23:30:31,032 [http-bio-8080-exec-8] DEBUG credentials.RequestParamsCredentialsExtractor - pswrd: test456
2015-04-03 23:30:31,032 [http-bio-8080-exec-8] DEBUG rest.RestAuthenticationFilter - Trying to authenticate the request: org.springframew[email protected]fdd5153a: Principal: [email protected]; Credentials: [PROTECTED]; Authenticated: false; Details: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Not granted any authorities
2015-04-03 23:30:31,051 [http-bio-8080-exec-8] DEBUG rest.RestAuthenticationFilter - Authentication failed: No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken
2015-04-03 23:30:31,051 [http-bio-8080-exec-8] DEBUG rest.RestAuthenticationFailureHandler - Setting status code to 401
2015-04-03 23:30:31,051 [http-bio-8080-exec-8] DEBUG rest.RestAuthenticationFilter - Not authenticated. Rest authentication token not generated.
Meine ein anderer Punkt ist der: Wenn ich eine Anfrage wie localhost:8080/restspring/api/guest/controller/action
(für nicht authentifizierte Anfrage) mache, muss ich einige Einträge in der URL-Zuordnung dafür machen? Meine Anwendung verwendet den benutzerdefinierten Authentifizierungsanbieter. Irgendeine Idee wird für mich hilfreich sein, danke.
Was ist Ihre Grails-Version? – Ramsharan
Ich verwende Grails Version 2.4.3, Wenn Sie weitere Informationen benötigen, dann lassen Sie mich bitte wissen, danke. – Abs
Haben Sie Memcached auf Ihrem PC installiert? http://alvarosanchez.github.io/grails-spring-security-rest/1.5.0.RC1/docs/guide/tokenStorage.html#memcached Und nicht auf die 401. Dieser Code nehmen Sie, wenn einige Fehler während LogIn (Sie konfigurieren es in der Konfiguration). Der letzte, wenn du dieses Ding vermisst. – Koloritnij