Skip to content

Initial OIDC support#15417

Merged
wing328 merged 3 commits intoOpenAPITools:masterfrom
jtama:enable-oidc
May 10, 2023
Merged

Initial OIDC support#15417
wing328 merged 3 commits intoOpenAPITools:masterfrom
jtama:enable-oidc

Conversation

@jtama
Copy link
Copy Markdown
Contributor

@jtama jtama commented May 4, 2023

Adds initial support for OpenID Connect security.

See #425

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • In case you are adding a new generator, run the following additional script :
    ./bin/utils/ensure-up-to-date.sh
    
    Commit all changed files.
  • File the PR against the correct branch: master (6.3.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
Copy link
Copy Markdown
Member

wing328 commented May 9, 2023

@jtama thanks for the PR. There's another PR that adds OpenID support. Can you please take a look at that to see if that meets your requirement?

#15407

@jtama
Copy link
Copy Markdown
Contributor Author

jtama commented May 9, 2023

I don't see any scope taken in account for oidc, which means they wont be able to generate @RolesAllowed annotations, or in my dedicate case, won't be able to generate proper documentation...

@wing328
Copy link
Copy Markdown
Member

wing328 commented May 9, 2023

what about we merge #15407 and they you can submit a PR on top to add support for scope?

@jtama
Copy link
Copy Markdown
Contributor Author

jtama commented May 9, 2023

Yes I can rebase after it has been merged.

@wing328
Copy link
Copy Markdown
Member

wing328 commented May 9, 2023

Just merged #15407.

Please rebase this PR when you've time.

jtama added 2 commits May 10, 2023 07:54
Changes OIDC to OpenIdConnect
Adds generated files
Copy link
Copy Markdown
Contributor

@ahmednfwela ahmednfwela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there were some OIDC shortcuts

@wing328
Copy link
Copy Markdown
Member

wing328 commented May 10, 2023

[ERROR] COMPILATION ERROR : 
[ERROR] /home/circleci/OpenAPITools/openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java:[47,19] variable openIdConnectUrl is already defined in class org.openapitools.codegen.CodegenSecurity
[ERROR] /home/circleci/OpenAPITools/openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java:[5307,19] cannot find symbol
  symbol:   variable isOpenId
  location: variable cs of type org.openapitools.codegen.CodegenSecurity
[ERROR] /home/circleci/OpenAPITools/openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java:[5374,74] cannot find symbol
  symbol:   variable isOpenId
  location: variable cs of type org.openapitools.codegen.CodegenSecurity
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project openapi-generator: Compilation failure: Compilation failure: 
[ERROR] /home/circleci/OpenAPITools/openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java:[47,19] variable openIdConnectUrl is already defined in class org.openapitools.codegen.CodegenSecurity
[ERROR] /home/circleci/OpenAPITools/openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java:[5307,19] cannot find symbol
[ERROR]   symbol:   variable isOpenId
[ERROR]   location: variable cs of type org.openapitools.codegen.CodegenSecurity
[ERROR] /home/circleci/OpenAPITools/openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java:[5374,74] cannot find symbol
[ERROR]   symbol:   variable isOpenId
[ERROR]   location: variable cs of type org.openapitools.codegen.CodegenSecurity
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command

the project wont' build. can you please take a look?

Comment thread docs/generators/apex.md
|BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3
|OpenIDConnect||OAS3
|OpenIDConnect||OAS3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these generators really support OpenIDConnect as part of the PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, but the pr check list said : Commit all changed files..

I wanted to separate preparatory work from generators work, cut into small chuncks ;)

public String type;
public String scheme;
public Boolean isBasic, isOAuth, isApiKey, isOpenId;
public Boolean isBasic, isOAuth, isApiKey, isOpenIdConnect;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I may not be very clear before.

I think using OpenID is fine to represent the security definition type.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't OpenId different from OpenIdConnect ? @wing328

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also according to the spec, it's openIdConnect

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the same thing.

also according to the spec, it's openIdConnect

Yup, so isOAuth should be named isOAuth2 instead if we simply follow that (but it's not the case)

I want to avoid mustache tags with long name if possible. That's why I suggest isOpenID instead.

Copy link
Copy Markdown
Member

@wing328 wing328 May 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's why I simply want to keep the naming introduced in #15407

it looks straightforward to me.

what do you guys think?

I don't mind using OpenIdConnect at all if that's what you guys prefer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean I don't mind, but it might confuse people to have some places with OpenId and others with OpenIdConnect, considering they are 2 different specs.
but an argument can be made here is that OpenId is deprecated, and it defaults to OpenIdConnect anyway.

so both is fine by me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I corrected all my rebase errors and left isOpenID too ease mustache templates. Just tell me If I should use isOpenIdConnect instead.

@wing328
Copy link
Copy Markdown
Member

wing328 commented May 10, 2023

looks good. I'll fix https://github.com/OpenAPITools/openapi-generator/actions/runs/4934037685/jobs/8819091825?pr=15417 after merging this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants