Skip to content

Commit d2c2e20

Browse files
OnBehalfOf claims take second duration (#10664)
OnBehalfOf claims take second duration Signed-off-by: Stephen Crawford <[email protected]>
1 parent 1715da5 commit d2c2e20

File tree

3 files changed

+9
-49
lines changed

3 files changed

+9
-49
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010
- Allow mmap to use new JDK-19 preview APIs in Apache Lucene 9.4+ ([#5151](https://github.com/opensearch-project/OpenSearch/pull/5151))
1111
- Add events correlation engine plugin ([#6854](https://github.com/opensearch-project/OpenSearch/issues/6854))
1212
- Introduce new dynamic cluster setting to control slice computation for concurrent segment search ([#9107](https://github.com/opensearch-project/OpenSearch/pull/9107))
13-
- Implement on behalf of token passing for extensions ([#8679](https://github.com/opensearch-project/OpenSearch/pull/8679))
13+
- Implement on behalf of token passing for extensions ([#8679](https://github.com/opensearch-project/OpenSearch/pull/8679), [#10664](https://github.com/opensearch-project/OpenSearch/pull/10664))
1414
- Provide service accounts tokens to extensions ([#9618](https://github.com/opensearch-project/OpenSearch/pull/9618))
1515
- [Admission control] Add enhancements to FS stats to include read/write time, queue size and IO time ([#10541](https://github.com/opensearch-project/OpenSearch/pull/10541))
1616
- [Admission control] Add Resource usage collector service and resource usage tracker ([#9890](https://github.com/opensearch-project/OpenSearch/pull/9890))

server/src/main/java/org/opensearch/identity/tokens/AuthToken.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
public interface AuthToken {
1717

1818
String asAuthHeaderValue();
19+
1920
}

server/src/main/java/org/opensearch/identity/tokens/OnBehalfOfClaims.java

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,17 @@
1414
public class OnBehalfOfClaims {
1515

1616
private final String audience;
17-
private final String subject;
18-
private final Long expiration;
19-
private final Long not_before;
20-
private final Long issued_at;
17+
private final Long expiration_seconds;
2118

2219
/**
2320
* Constructor for OnBehalfOfClaims
2421
* @param aud the Audience for the token
25-
* @param subject the subject of the token
26-
* @param expiration the expiration time in seconds for the token
27-
* @param not_before the not_before time in seconds for the token
28-
* @param issued_at the issued_at time in seconds for the token
29-
*/
30-
public OnBehalfOfClaims(String aud, String subject, Long expiration, Long not_before, Long issued_at) {
31-
this.audience = aud;
32-
this.subject = subject;
33-
this.expiration = expiration;
34-
this.not_before = not_before;
35-
this.issued_at = issued_at;
36-
}
37-
38-
/**
39-
* A constructor that sets a default issued at time of the current time
40-
* @param aud the Audience for the token
41-
* @param subject the subject of the token
42-
* @param expiration the expiration time in seconds for the token
43-
* @param not_before the not_before time in seconds for the token
44-
*/
45-
public OnBehalfOfClaims(String aud, String subject, Long expiration, Long not_before) {
46-
this(aud, subject, expiration, not_before, System.currentTimeMillis() / 1000);
47-
}
22+
* @param expiration_seconds the length of time in seconds the token is valid
4823
49-
/**
50-
* A constructor which sets a default not before time of the current time
51-
* @param aud the Audience for the token
52-
* @param subject the subject of the token
53-
* @param expiration the expiration time in seconds for the token
5424
*/
55-
public OnBehalfOfClaims(String aud, String subject, Long expiration) {
56-
this(aud, subject, expiration, System.currentTimeMillis() / 1000);
25+
public OnBehalfOfClaims(String aud, Long expiration_seconds) {
26+
this.audience = aud;
27+
this.expiration_seconds = expiration_seconds;
5728
}
5829

5930
/**
@@ -62,26 +33,14 @@ public OnBehalfOfClaims(String aud, String subject, Long expiration) {
6233
* @param subject the subject of the token
6334
*/
6435
public OnBehalfOfClaims(String aud, String subject) {
65-
this(aud, subject, System.currentTimeMillis() / 1000 + 300);
36+
this(aud, 300L);
6637
}
6738

6839
public String getAudience() {
6940
return audience;
7041
}
7142

72-
public String getSubject() {
73-
return subject;
74-
}
75-
7643
public Long getExpiration() {
77-
return expiration;
78-
}
79-
80-
public Long getNot_before() {
81-
return not_before;
82-
}
83-
84-
public Long getIssued_at() {
85-
return issued_at;
44+
return expiration_seconds;
8645
}
8746
}

0 commit comments

Comments
 (0)