-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mix of authentication, backend, frontend works
- Loading branch information
1 parent
2dfb24e
commit 5b33f20
Showing
58 changed files
with
330 additions
and
1,360 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
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
31 changes: 31 additions & 0 deletions
31
...rvice/src/main/java/dev/agasen/ecom/inventory/auth/resourceserver/EcomAuthentication.java
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,31 @@ | ||
package dev.agasen.ecom.inventory.auth.resourceserver; | ||
|
||
import java.util.Collection; | ||
|
||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.oauth2.jwt.Jwt; | ||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; | ||
|
||
|
||
|
||
public class EcomAuthentication extends JwtAuthenticationToken { | ||
/** | ||
* | ||
* A Custom Authentication object used to reshape the JWT token | ||
* | ||
*/ | ||
|
||
private final String priority; | ||
|
||
public EcomAuthentication(Jwt jwt, Collection<? extends GrantedAuthority> authorities, String priority) { | ||
super(jwt, authorities); | ||
|
||
// we are adding a new field to the JwtAuthenticationToken class | ||
// this priority field is in a claim in the JWT token | ||
this.priority = priority; | ||
} | ||
|
||
public String getPriority() { | ||
return priority; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...in/java/dev/agasen/ecom/inventory/auth/resourceserver/EcomJwtAuthenticationConverter.java
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,24 @@ | ||
package dev.agasen.ecom.inventory.auth.resourceserver; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.oauth2.jwt.Jwt; | ||
import org.springframework.stereotype.Component; | ||
|
||
import reactor.core.publisher.Mono; | ||
|
||
@Component | ||
public class EcomJwtAuthenticationConverter implements Converter<Jwt, Mono<EcomAuthentication>>{ | ||
|
||
@Override | ||
public Mono<EcomAuthentication> convert(Jwt source) { | ||
List<GrantedAuthority> authorities = List.of(() -> "read"); | ||
|
||
String priority = String.valueOf(source.getClaims().get("priority")); | ||
|
||
return Mono.just(new EcomAuthentication(source, authorities, priority)); | ||
} | ||
|
||
} |
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
2 changes: 1 addition & 1 deletion
2
...th/resourceserver/EcomAuthentication.java → ...th/resourceserver/EcomAuthentication.java
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
2 changes: 1 addition & 1 deletion
2
...erver/EcomJwtAuthenticationConverter.java → ...erver/EcomJwtAuthenticationConverter.java
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
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
Oops, something went wrong.