Skip to content

Commit

Permalink
Whisper jwt audience (#516)
Browse files Browse the repository at this point in the history
* transcription: add jwt audience param for asap

* transcription: add jwt audience sample property
  • Loading branch information
rpurdel authored Feb 7, 2024
1 parent 6c8319c commit 411d7ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions jigasi-home/sip-communicator.properties
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ org.jitsi.jigasi.xmpp.acc.USE_DEFAULT_STUN_SERVER=false

# Whisper live transcription server
# org.jitsi.jigasi.transcription.customService=org.jitsi.jigasi.transcription.WhisperTranscriptionService
# org.jitsi.jigasi.transcription.whisper.jwt_audience=jitsi
# org.jitsi.jigasi.transcription.whisper.private_key=<SINGLE LINE SSH-KEYGEN PRIVATE KEY>
# org.jitsi.jigasi.transcription.whisper.private_key_name=<A_UNIQUE_ID_FOR_THE_KEY_NO_SPACES>
# org.jitsi.jigasi.transcription.whisper.websocket_url=ws://localhost:8000/ws/
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/jitsi/jigasi/transcription/WhisperWebsocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public class WhisperWebsocket
private final static Logger logger
= Logger.getLogger(WhisperWebsocket.class);

/**
* JWT audience for the Whisper service.
*/
public final static String JWT_AUDIENCE
= "org.jitsi.jigasi.transcription.whisper.jwt_audience";

/**
* The config key of the websocket to the speech-to-text service.
*/
Expand Down Expand Up @@ -98,6 +104,8 @@ public class WhisperWebsocket

private String privateKeyName;

private String jwtAudience;


private String getJWT() throws NoSuchAlgorithmException, InvalidKeySpecException
{
Expand All @@ -109,6 +117,7 @@ private String getJWT() throws NoSuchAlgorithmException, InvalidKeySpecException
JwtBuilder builder = Jwts.builder()
.setHeaderParam("kid", privateKeyName)
.setIssuedAt(now)
.setAudience(jwtAudience)
.setIssuer("jigasi")
.signWith(finalPrivateKey, SignatureAlgorithm.RS256);
long expires = nowMillis + (60 * 5 * 1000);
Expand Down Expand Up @@ -140,6 +149,8 @@ private void generateWebsocketUrl()

private void getConfig()
{
jwtAudience = JigasiBundleActivator.getConfigurationService()
.getString(JWT_AUDIENCE, "jitsi");
websocketUrlConfig = JigasiBundleActivator.getConfigurationService()
.getString(WEBSOCKET_URL, DEFAULT_WEBSOCKET_URL);
if (websocketUrlConfig.endsWith("/"))
Expand Down

0 comments on commit 411d7ae

Please sign in to comment.