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: 3 months 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 7 years ago)
- Default Branch: master
- Last Pushed: 2025-04-09T05:55:10.000Z (3 months ago)
- Last Synced: 2025-04-10T05:09:10.415Z (3 months ago)
- Topics: access-control, authentication, authorization, jwt, role-based-access-control, role-based-authorization
- Language: Java
- Homepage: http://scalecube.io
- Size: 383 KB
- Stars: 7
- Watchers: 14
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# scalecube-security
[](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)
```