Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use self-signed JWTs if alwaysUseJWTAccessWithScope is true #1196

Merged
merged 31 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3e0c6b1
feat: add alwaysUseJWTAccess variable
sofisl Jun 23, 2021
b9dd1fe
npm run lint
sofisl Jun 23, 2021
a7d97f3
feat: add JWT access logic
sofisl Jun 25, 2021
6087835
fix: get useJWTAccess from generator
sofisl Jun 26, 2021
0ce0c41
Merge branch 'master' into selfSignedWork
SurferJeffAtGoogle Jun 28, 2021
32275cd
WIP: adding tests
SurferJeffAtGoogle Jun 30, 2021
af3a317
Merge branch 'master' into selfSignedWork
sofisl Jul 1, 2021
8f1b93a
Merge branch 'selfSignedWork' of github.com:googleapis/google-auth-li…
SurferJeffAtGoogle Jul 1, 2021
f99b8e2
fix: address comments
sofisl Jul 1, 2021
72b7f54
merge incoming changes
sofisl Jul 1, 2021
61cac31
fix: add tests
sofisl Jul 2, 2021
237a20a
npm run fix
sofisl Jul 2, 2021
46c1819
fix: remove variables from interface
sofisl Jul 2, 2021
40a5b10
empty
sofisl Jul 2, 2021
f94e774
fix: resolve merge conflicts
sofisl Jul 29, 2021
8e6b8d7
fix merge conflicts
sofisl Jul 29, 2021
41bf440
fix: update tests for correct type
sofisl Jul 29, 2021
9b994bc
address comments
sofisl Jul 29, 2021
2d61c65
fix: use updated variable name for self-signed JWT
sofisl Aug 13, 2021
ab7a117
fix: address comments related to precedence for self-signed JWT
sofisl Aug 26, 2021
936b0f9
Merge branch 'master' into selfSignedWork
bcoe Aug 26, 2021
01113f0
run auth
sofisl Aug 26, 2021
9eee4a5
fix: set defaultService to take precedence
sofisl Aug 26, 2021
9cdece5
fix: set defaultService as the default audience to sign a JWT with
sofisl Aug 26, 2021
b858d29
fix: change logic to comply with useSelfSignedJWT truth table
sofisl Aug 27, 2021
cdfc275
remove comment
sofisl Aug 27, 2021
71c9e12
fix: write final tests for auth decision matrix, add logic for cached…
sofisl Aug 30, 2021
0fef13e
Merge branch 'master' into selfSignedWork
bcoe Aug 30, 2021
42f5fc9
Update src/auth/jwtclient.ts
bcoe Aug 30, 2021
40f6ae7
Update test/test.jwt.ts
bcoe Aug 30, 2021
8035def
chore: keep one test using old approach
bcoe Aug 30, 2021
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
3 changes: 3 additions & 0 deletions src/auth/baseexternalclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ export abstract class BaseExternalAccountClient extends AuthClient {
public projectNumber: string | null;
public readonly eagerRefreshThresholdMillis: number;
public readonly forceRefreshOnFailure: boolean;
public useJWTAccessAlways?: boolean;
public defaultServicePath?: string;


/**
* Instantiate a BaseExternalAccountClient instance using the provided JSON
Expand Down
2 changes: 2 additions & 0 deletions src/auth/refreshclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export class UserRefreshClient extends OAuth2Client {
// In a future gts release, the _propertyName rule will be lifted.
// This is also a hard one because `this.refreshToken` is a function.
_refreshToken?: string | null;
public useJWTAccessAlways?: boolean;
public defaultServicePath?: string;

/**
* User Refresh Token credentials.
Expand Down
14 changes: 14 additions & 0 deletions test/test.googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,20 @@ describe('googleauth', () => {
assert.strictEqual(json.private_key, (result as JWT).key);
});

it.only('fromJSON should set default access variable with private key', () => {
sofisl marked this conversation as resolved.
Show resolved Hide resolved
auth.useJWTAccessAlways = true;
const json = createJwtJSON();
const result = auth.fromJSON(json);
assert.ok(result.useJWTAccessAlways);
});

it.only('fromJSON should set default service path with private key', () => {
auth.defaultServicePath = 'a/b/c';
const json = createJwtJSON();
const result = auth.fromJSON(json);
assert.strictEqual(result.defaultServicePath, 'a/b/c');
});

it('fromJSON should create JWT with null scopes', () => {
const json = createJwtJSON();
const result = auth.fromJSON(json);
Expand Down