Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scalecube/scalecube-security
Authentication and Authorization library for scalecube services.
https://github.com/scalecube/scalecube-security
access-control authentication authorization jwt role-based-access-control role-based-authorization
Last synced: about 17 hours ago
JSON representation
Authentication and Authorization library for scalecube services.
- Host: GitHub
- URL: https://github.com/scalecube/scalecube-security
- Owner: scalecube
- License: apache-2.0
- Created: 2018-03-29T09:38:44.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-12T08:24:11.000Z (7 months ago)
- Last Synced: 2024-04-12T15:30:24.647Z (7 months ago)
- Topics: access-control, authentication, authorization, jwt, role-based-access-control, role-based-authorization
- Language: Java
- Homepage: http://scalecube.io
- Size: 343 KB
- Stars: 7
- Watchers: 17
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# scalecube-security
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e110b177bb1b4f6aaf86a4e77fc795c5)](https://app.codacy.com/app/ScaleCube/scalecube-security?utm_source=github.com&utm_medium=referral&utm_content=scalecube/scalecube-security&utm_campaign=badger)
# JWT authentication basic usage
Given a JWT we would like to authenticate it and extract its claims:
Generating JWT for example:
``` java
String hmacSecret = "secert";String token = Jwts.builder().setAudience("anAudience")
.setSubject("aSubject")
.signWith(SignatureAlgorithm.HS256, hmacSecret.getBytes())
.compact();
```Authenticating the JWT:
``` java
JwtAuthenticator authenticator = new JwtAuthenticatorImpl
.Builder()
.keyResolver(map -> Optional.of(new SecretKeySpec(hmacSecret.getBytes(), "HMACSHA256")))
.build();
Profile profile = authenticator.authenticate(token)
```