-
Notifications
You must be signed in to change notification settings - Fork 154
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
Make JWT brokers injectable #570
base: main
Are you sure you want to change the base?
Conversation
private String file; | ||
private String secret; | ||
|
||
public String getType() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect you need some @JsonSetter
annotations here for Jackson? (#561)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or a @JsonCreator
constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Need" in what sense? It works "as is" as the receiver of the DW YAML config data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added @JsonProperty
for clarity.
|
||
@Override | ||
public TokenBroker apply(RealmContext realmContext) { | ||
if (file == null && secret == null) { | ||
String secret = config.secret(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this check can be moved to the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but I did not want to alter behaviour is this PR. Let's me know and I will move the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm for checking in the constructor, FWIW
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored (and rebased)
config.maxTokenGenerationInSeconds()); | ||
} | ||
|
||
public interface Config { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better / simpler to have one config interface for all token broker factories?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to a unified config interface.
private String file; | ||
private String secret; | ||
|
||
public String getType() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or a @JsonCreator
constructor?
} | ||
|
||
public interface Config { | ||
int maxTokenGenerationInSeconds(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int maxTokenGenerationInSeconds(); | |
Duration maxTokenGeneration(); |
(but I don't know if DW has support for java time)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not want to introduce functional changes in this PR. It's just a refactoring for injectability.
826d70a
to
29bbfb3
Compare
* Detach `TokenBrokerFactory` sub-classes from Jackson-based config parsing logic. * Add a new unified `TokenBrokerConfig` under DW to hold JWT config data. * Resolve JWT factories through HK2 named service lookup, using the type name from `TokenBrokerConfig` * Add dedicated class `NoneTokenBrokerFactory` for the default do-nothing token broker implementation. * Yaml config (`polaris-server.yml`) is not affected
29bbfb3
to
b4ea9e3
Compare
b4ea9e3
to
39891f5
Compare
Detach
TokenBrokerFactory
sub-classes from Jackson-based config parsing logic.Add a new unified
TokenBrokerConfig
under DW to hold JWT config data.Resolve JWT factories through HK2 named service lookup, using the type name from
TokenBrokerConfig
Add dedicated class
NoneTokenBrokerFactory
for the default do-nothing token broker implementation.Yaml config (
polaris-server.yml
) is not affected