This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #792 from KenjiChao/kenjichao/configurable_auth_he…
…ader Add a custom header to parse the caller Spiffe Id from
- Loading branch information
Showing
6 changed files
with
315 additions
and
33 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
server/src/main/java/keywhiz/auth/mutualssl/SpiffePrincipal.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,29 @@ | ||
package keywhiz.auth.mutualssl; | ||
|
||
import java.net.URI; | ||
import java.security.Principal; | ||
|
||
public class SpiffePrincipal implements Principal { | ||
private final URI spiffeId; | ||
|
||
public SpiffePrincipal(URI spiffeId) { | ||
this.spiffeId = spiffeId; | ||
} | ||
|
||
@Override public String getName() { | ||
return spiffeId.toString(); | ||
} | ||
|
||
public URI getSpiffeId() { | ||
return spiffeId; | ||
} | ||
|
||
/** | ||
* Use the workload id of a Spiffe Id as the client name. | ||
*/ | ||
public String getClientName() { | ||
String path = spiffeId.getPath(); | ||
// Drop the leading '/' character. | ||
return path.isEmpty() ? path : path.substring(1); | ||
} | ||
} |
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.