swagger-api / swagger-api/swagger-codegen
[JAVA] Feature add support for two-legged OAuth2
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Referencing to Google's documentation; in the case of authenticating server-to-server applications with two-legged OAuth2 is possible. This requires sending grant_type and assertion parameters to token_url.
Swagger declaration file content
I have already sent a PR to APIs-guru for adding token_url to their yaml definitions. See https://github.com/APIs-guru/openapi-directory/pull/116
Suggest a Fix
An additional OAuth flow can be added;
public void setFlow(OAuthFlow flow) {
switch(flow) {
// ...
case application:
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
break;
case twoLeggedAuth:
tokenRequestBuilder.setGrantType(GrantType.JWT_BEARER);
tokenRequestBuilder.setAssertion("assertion");
break;
default:
break;
}
}
assertion can be calculated as in this apache oltu example.
What do you think? If you want, I can give a try and send a PR.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Java OAuth flow handling around setFlow(OAuthFlow) and the tokenRequestBuilder. Review how token_url is represented and how GrantType values are sent, then compare the proposed application and twoLeggedAuth flows with the linked OAuth2 references. Done means server-to-server authentication can send the required grant_type and assertion parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, authentication
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100