Defining classes for each role

We have scoped our roles, so we need to create proper classes. Create a new package called security. The first class we will create will be the class that represents user definition. Create a class called User and make sure it extends the UserDetails class from the org.springframework.security.core.userdetails package:

package com.journaler.api.security ... import org.springframework.security.core.GrantedAuthority import org.springframework.security.core.userdetails.UserDetails ... open class User : UserDetails { override fun getAuthorities(): MutableCollection<out GrantedAuthority> { ... } override fun isEnabled(): Boolean { ... } override fun getUsername(): String { ... } override fun isCredentialsNonExpired(): ...

Get Building Applications with Spring 5 and Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.