{"id":19300262,"url":"https://github.com/zenliucn/easy-security","last_synced_at":"2026-05-16T06:03:32.926Z","repository":{"id":42533927,"uuid":"189750616","full_name":"ZenLiuCN/easy-security","owner":"ZenLiuCN","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-01T04:46:44.000Z","size":88,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T01:30:07.069Z","etag":null,"topics":["easy","security","spring"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZenLiuCN.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-01T15:48:41.000Z","updated_at":"2022-04-01T04:46:39.000Z","dependencies_parsed_at":"2022-09-04T10:22:29.935Z","dependency_job_id":null,"html_url":"https://github.com/ZenLiuCN/easy-security","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ZenLiuCN/easy-security","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZenLiuCN%2Feasy-security","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZenLiuCN%2Feasy-security/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZenLiuCN%2Feasy-security/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZenLiuCN%2Feasy-security/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZenLiuCN","download_url":"https://codeload.github.com/ZenLiuCN/easy-security/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZenLiuCN%2Feasy-security/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284711515,"owners_count":27050939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["easy","security","spring"],"created_at":"2024-11-09T23:14:15.936Z","updated_at":"2025-11-16T13:01:17.106Z","avatar_url":"https://github.com/ZenLiuCN.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# easy wapper for spring security\n[![](https://jitpack.io/v/ZenLiuCN/easy-security.svg)](https://jitpack.io/#ZenLiuCN/easy-security)\nmake it easy to use spring security with srpingmvc or webflux\n\n## useage\nimplementation of AuthAuthneticationRepository\n```kotlin\ninterface AuthAuthenticationRepository {\n\t/**\n\t * function to validate token\n\t * @param token String\n\t * @return Boolean\n\t */\n\tfun validateToken(token: String?): Boolean\n\n\t/**\n\t * load user Authentication by token,failed with null\n\t * @param token String\n\t * @return PreAuthenticatedAuthenticationToken?\n\t */\n\tfun loadFromToken(token: String): PreAuthenticatedAuthenticationToken?\n}\n```\nImplementation of PreAuthenticatedAauthenticationToken\n```kotlin\ndata class AuthedToken(\n    val token: String,\n    val user: String,\n    val roles: List\u003cRole\u003e\n) : PreAuthenticatedAuthenticationToken(token, user, roles)\n\ndata class Role(\n    val role: String\n) : GrantedAuthority {\n    override fun getAuthority(): String = role\n}\n```\ncontroll access\n```ktolin\n@RestController\nclass Controller(private val auth: AuthConfiguration) {\n    @PreAuthorize(\"permitAll() or isAnonymous()\") //Any one can access\n    @GetMapping(\"/login\")\n    fun login() = auth.doLogin().toMono()\n\n    @PreAuthorize(\"hasAnyRole('ROLE_USER')\") //only user with ROLE_USER can access\n    @GetMapping(\"/status\")\n    fun status() = auth.status().toMono()\n\n}\n```\n## configuration\n```kotlin\n@ConfigurationProperties(\"authnetication\")\nclass AuthProperties {\n\tvar tokenName: String = \"token\"\n\tvar tokenFailedStatusCode: Int = HttpStatus.UNAUTHORIZED.value()\n\tvar tokenFailedMessage: String = \"\"\n\tvar exceptionIfTokenMissing: Boolean = false\n\tvar enableAnonymous: Boolean = true\n\tvar anonymousAuthority: String = \"ANONYMOUS\"\n\tvar rolePrefix: String = \"ROLE_\"\n\tvar useCRSF: Boolean = false\n\tvar permitUrl: Map\u003cString, Collection\u003cString\u003e\u003e = mapOf()\n\t/**\n\t * those url will redirect to https\n\t */\n\tvar tlsOnly: Collection\u003cString\u003e = mutableListOf()\n\t//must defined while use tlsOnly\n\tvar http: Int=8080\n\tvar https:Int=8081\n}\n\n```\n```yaml\nspring:\n  main:\n    allow-bean-definition-overriding: true\nauthnetication:\n  permitUrl:\n    ROLE_ADMIN:\n        - /hello\n  tlsOnly:\n    - /https\n  http: 8011\n  https: 8010\n```\n## more detialed example plz to see test in source\n**note** should comment `starter-web` dependency before test on reactive environment\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenliucn%2Feasy-security","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenliucn%2Feasy-security","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenliucn%2Feasy-security/lists"}