Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/main/java/com/spotify/github/v3/clients/JwtTokenIssuer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package com.spotify.github.v3.clients;

import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
Expand All @@ -34,7 +33,6 @@
/** The helper Jwt token issuer. */
public class JwtTokenIssuer {

private static final SignatureAlgorithm SIGNATURE_ALGORITHM = SignatureAlgorithm.RS256;
private static final long TOKEN_TTL = 600000;

private final PrivateKey signingKey;
Expand Down Expand Up @@ -69,12 +67,14 @@ public static JwtTokenIssuer fromPrivateKey(final byte[] privateKey)
*/
public String getToken(final Integer appId) {
return Jwts.builder()
.setId("github-auth")
.setSubject("authenticating via private key")
.setIssuer(String.valueOf(appId))
.signWith(signingKey, SIGNATURE_ALGORITHM)
.setExpiration(new Date(System.currentTimeMillis() + TOKEN_TTL))
.setIssuedAt(new Date())
.claims()
.id("github-auth")
.subject("authenticating via private key")
.issuer(String.valueOf(appId))
.issuedAt(new Date())
.expiration(new Date(System.currentTimeMillis() + TOKEN_TTL))
.and()
.signWith(signingKey, Jwts.SIG.RS256)
.compact();
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/spotify/github/v3/repos/RepositoryBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public interface RepositoryBase extends UpdateTracking {
@Nullable
Integer id();

/** Node id */
@Nullable
String nodeId();

/** Name */
@Nullable
String name();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void setUp() throws Exception {
public void testDeserialization() throws IOException {
final Repository repository = Json.create().fromJson(fixture, Repository.class);
assertThat(repository.id(), is(1296269));
assertThat(repository.nodeId(), is("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"));
assertUser(repository.owner());
assertThat(repository.name(), is("Hello-World"));
assertThat(repository.fullName(), is(repository.owner().login() + "/Hello-World"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": 1296269,
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
"owner": {
"login": "octocat",
"id": 1,
Expand Down