#Spring Security Mongo
Library to provide full implementation of all the repositories and provider necessary to have all the security persisted in MongoDB.
- ApprovalStore
- ClientDetailsService
- ClientRegistrationService
- TokenStore
- UserDetailsManager
- ClientTokenServices
##How to use it
Add as dependency to your project and then use the beans in your Spring Oauth2 Configuration
Add this annotation to your configuration class:
@Configuration
@EnableSecurityMongo
public class MongoSecurityConfiguration {
}
Having this annotation will define in your spring context all the necessary to use this library.
define the following properties in your app:
mongo.host=localhost
mongo.port=27017
mongo.database=testdb
mongo.username=testuser
mongo.password=testpassword
You can produce the json to create in your mongo instance the users by executing some of the integration tests or just insert this json:
Mongo User
{
"_id" : "testuser",
"_class" : "uk.co.caeldev.springsecuritymongo.domain.User",
"password" : "testpassword",
"userUUID" : LUUID("03479d48-93cf-5e55-974f-842eb0200ca8"),
"authorities" : [
{
"role" : "ROLE_USER",
"_class" : "org.springframework.security.core.authority.SimpleGrantedAuthority"
}
],
"accountNonExpired" : true,
"accountNonLocked" : true,
"credentialsNonExpired" : true,
"enabled" : true
}
Mongo Client Detail
{
"_id" : "testclient",
"_class" : "uk.co.caeldev.springsecuritymongo.domain.MongoClientDetails",
"clientSecret" : "testclientsecret",
"scope" : [
"read"
],
"resourceIds" : [
"oauth2-resource"
],
"authorizedGrantTypes" : [
"authorization_code",
"implicit"
],
"registeredRedirectUris" : [
"http://www.google.co.uk"
],
"authorities" : [
{
"role" : "ROLE_CLIENT",
"_class" : "org.springframework.security.core.authority.SimpleGrantedAuthority"
}
],
"accessTokenValiditySeconds" : 30000.0000000000000000,
"refreshTokenValiditySeconds" : 30000.0000000000000000,
"additionalInformation" : {},
"autoApproveScopes" : [
""
]
}