Skip to content

Commit

Permalink
Makes User implement UserDetails to work with Spring Security (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Tomsu committed May 3, 2016
1 parent 4a1e8cc commit 08dfbb0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions kork-security/kork-security.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dependencies {
compile spinnaker.dependency('springSecurityCore')
compile spinnaker.dependency('groovy')
spinnaker.group('spockBase')
spinnaker.group('jackson')

compile spinnaker.dependency('slf4j')
testCompile 'ch.qos.logback:logback-classic:1.1.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@

package com.netflix.spinnaker.security

import com.fasterxml.jackson.annotation.JsonIgnore
import groovy.transform.Immutable
import org.springframework.security.core.authority.SimpleGrantedAuthority
import org.springframework.security.core.userdetails.UserDetails

/**
* User implements UserDetails in order to properly hook into the Spring Security framework.
*/
@Immutable
class User implements Serializable {
class User implements Serializable, UserDetails {
static final long serialVersionUID = 7392392099262597885L

String email
Expand All @@ -28,4 +34,25 @@ class User implements Serializable {

Collection<String> roles
Collection<String> allowedAccounts = []

@Override
List getAuthorities() {
roles?.collect { new SimpleGrantedAuthority(it) }
}

/** Not used **/
String username
@JsonIgnore String password

@Override
boolean isAccountNonExpired() { return true }

@Override
boolean isAccountNonLocked() { return true }

@Override
boolean isCredentialsNonExpired() { return true }

@Override
boolean isEnabled() { return true }
}

0 comments on commit 08dfbb0

Please sign in to comment.