-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
87 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Change Log | ||
|
||
## [1.0.0-rc.1](https://github.com/auth0/java-jwt/tree/1.0.0-rc.1) (2016-12-19) | ||
|
||
Auth0 integration with Spring Security to add authorization to your API using JWTs | ||
|
||
## Download | ||
|
||
Get Auth0 Spring Security API using Maven: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.github.auth0</groupId> | ||
<artifactId>auth0-spring-security-api</artifactId> | ||
<version>1.0.0-rc.1</version> | ||
</dependency> | ||
``` | ||
|
||
or Gradle: | ||
|
||
```gradle | ||
compile 'com.auth0.github:auth0-spring-security-api:1.0.0-rc.1' | ||
``` | ||
|
||
## Usage | ||
|
||
Inside a `WebSecurityConfigurerAdapter` you can configure your api to only accept `RS256` signed JWTs | ||
|
||
```java | ||
@EnableWebSecurity | ||
@Configuration | ||
public class SecurityConfig extends WebSecurityConfigurerAdapter { | ||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
JwtWebSecurityConfigurer | ||
.forRS256("YOUR_API_AUDIENCE", "YOUR_API_ISSUER") | ||
.configure(http); | ||
} | ||
} | ||
``` | ||
|
||
or for `HS256` signed JWTs | ||
|
||
```java | ||
@EnableWebSecurity | ||
@Configuration | ||
public class SecurityConfig extends WebSecurityConfigurerAdapter { | ||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
JwtWebSecurityConfigurer | ||
.forHS256WithBase64Secret("YOUR_API_AUDIENCE", "YOUR_API_ISSUER", "YOUR_BASE_64_ENCODED_SECRET") | ||
.configure(http); | ||
} | ||
} | ||
``` | ||
|
||
|
||
Then using Spring Security `HttpSecurity` you can specify which paths requires authentication | ||
|
||
```java | ||
http.authorizeRequests() | ||
.antMatchers("/api/**").fullyAuthenticated(); | ||
``` | ||
|
||
and you can even specify that the JWT should have a single or several scopes | ||
|
||
```java | ||
http.authorizeRequests() | ||
.antMatchers(HttpMethod.GET, "/api/users/**").hasAuthority("read:users"); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,16 +11,16 @@ oss { | |
|
||
developers { | ||
auth0 { | ||
displayName = "Auth0" | ||
email = "[email protected]" | ||
displayName = 'Auth0' | ||
email = '[email protected]' | ||
} | ||
lbalmaceda { | ||
displayName = "Luciano Balmaceda" | ||
email = "[email protected]" | ||
displayName = 'Luciano Balmaceda' | ||
email = '[email protected]' | ||
} | ||
hzalaz { | ||
displayName = "Hernan Zalazar" | ||
email = "[email protected]" | ||
displayName = 'Hernan Zalazar' | ||
email = '[email protected]' | ||
} | ||
} | ||
|
||
|
@@ -58,12 +58,11 @@ jacocoTestReport { | |
|
||
test { | ||
testLogging { | ||
events "passed", "skipped", "failed", "standardError" | ||
exceptionFormat "short" | ||
events 'passed', 'skipped', 'failed', 'standardError' | ||
exceptionFormat 'short' | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
delete 'CHANGELOG.md.release' | ||
} | ||
clean.doFirst { | ||
new File('CHANGELOG.md.release').delete() | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.