grails / grails-spring-security-rest

Grails plugin to implement token-based, RESTful authentication using Spring Security
http://alvarosanchez.github.io/grails-spring-security-rest/
Other
203 stars 117 forks source link

Token not generated for Grails 3 app #352

Closed vortex1911 closed 6 years ago

vortex1911 commented 7 years ago

I recently upgraded grails app from 2.5.3 to 3.1.8. I have updated all the plugins. But when I make the api call to the app it throws me the following error.

DEBUG org.springframework.security.web.util.matcher.AntPathRequestMatcher - Checking match of request : '/mapi/login'; against '/mapi/**'
DEBUG org.springframework.security.web.FilterChainProxy - /mapi/login at position 1 of 7 in additional filter chain; firing Filter: 'SecurityRequestHolderFilter'
DEBUG org.springframework.security.web.FilterChainProxy - /mapi/login at position 2 of 7 in additional filter chain; firing Filter: 'MutableLogoutFilter'
DEBUG org.springframework.security.web.util.matcher.AntPathRequestMatcher - Checking match of request : '/mapi/login'; against '/logoff'
DEBUG org.springframework.security.web.FilterChainProxy - /mapi/login at position 3 of 7 in additional filter chain; firing Filter: 'RestAuthenticationFilter'
DEBUG grails.plugin.springsecurity.rest.RestAuthenticationFilter - Actual URI is /mapi/login; endpoint URL is /mapi/login
DEBUG grails.plugin.springsecurity.rest.RestAuthenticationFilter - Applying authentication filter to this request
DEBUG grails.plugin.springsecurity.rest.credentials.DefaultJsonPayloadCredentialsExtractor - Extracted credentials from JSON payload. Username: 20-2330 KEITH ONG, password: [PROTECTED]
DEBUG grails.plugin.springsecurity.rest.RestAuthenticationFilter - Trying to authenticate the request
INFO org.springframework.security.core.SpringSecurityCoreVersion - You are running with Spring Security Core 4.0.4.RELEASE
DEBUG org.springframework.security.authentication.ProviderManager - Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
DEBUG grails.plugin.springsecurity.rest.RestAuthenticationFilter - Authentication failed: Could not obtain current Hibernate Session; nested exception is org.hibernate.HibernateException: No Session found for current thread
DEBUG grails.plugin.springsecurity.rest.token.bearer.BearerTokenReader - Looking for bearer token in Authorization header, query string or Form-Encoded body parameter
DEBUG grails.plugin.springsecurity.rest.token.bearer.BearerTokenReader - No token found
DEBUG grails.plugin.springsecurity.rest.token.bearer.BearerTokenReader - Token: null
DEBUG grails.plugin.springsecurity.rest.token.bearer.BearerTokenAuthenticationFailureHandler - Sending status code 401 and header WWW-Authenticate: Bearer
DEBUG grails.plugin.springsecurity.rest.RestAuthenticationFilter - Not authenticated. Rest authentication token not generated.

Here's my build.gradle contents

buildscript {
    ext {
        grailsVersion = project.grailsVersion
    }
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.8.2"
        classpath "org.grails.plugins:hibernate4:5.0.13"
    }
}

version "0.1"
group "portalapp"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"asset-pipeline"
apply plugin:"codenarc"

ext {
    grailsVersion = project.grailsVersion
    gradleWrapperVersion = project.gradleWrapperVersion
}

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
    maven { url "https://dl.bintray.com/purpleraven/plugins"}
    maven { url "https://dl.bintray.com/9ci/grails-plugins"}
    maven { url "https://dl.bintray.com/longwa/plugins/"}

}

dependencyManagement {
    imports {
        mavenBom "org.grails:grails-bom:$grailsVersion"
    }
    applyMavenExclusions false
}

grails {
    plugins {
        compile project(':portalservice')
    }
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-dependencies"
    compile "org.grails:grails-web-boot"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:hibernate4"
    compile "org.hibernate:hibernate-ehcache"
    console "org.grails:grails-console"
    profile "org.grails.profiles:web:3.1.8"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
    runtime "com.h2database:h2"
    testCompile "org.grails:grails-plugin-testing"
    testCompile "org.grails.plugins:geb"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
    compile "org.grails.plugins:hibernate5"
    compile 'org.grails.plugins:grails-melody-plugin:1.60.1'
    runtime 'org.grails.plugins:grails-console:2.0.0'
    compile 'org.grails.plugins:redis:2.0.4'
    compile 'org.grails.plugins:quartz-monitor:1.3'
    compile 'org.grails.plugins:quartz:2.0.12'
    compile 'org.grails.plugins:aws-sdk:1.10.74'
    compile 'org.grails.plugins:mongodb:5.0.3'
    compile "org.grails.plugins:java8-temporal:0.2"
    compile "org.grails.plugins:csv:1+"
    compile "org.grails.plugins:spring-security-rest:2.0.0.M2"
    compile 'org.grails.plugins:fixtures:2.0.1'
//    compile 'org.grails:grails-datastore-rest-client:5.0.0.RC2'
    compile 'org.grails.plugins:build-test-data:3.0.1'
    compile 'org.grails.plugins:rest-client-builder:3.0.0.M1'
    compile 'org.grails.plugins:grails-platform-core:3.0.3'
}

assets {
    minifyJs = true
    minifyCss = true
}
volnei commented 6 years ago

Take a look on this https://github.com/grails-plugins/grails-spring-security-core/issues/378