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

LINE OAuth Strategy #57

Closed
wingyplus opened this issue Oct 13, 2020 · 5 comments · Fixed by #58
Closed

LINE OAuth Strategy #57

wingyplus opened this issue Oct 13, 2020 · 5 comments · Fixed by #58

Comments

@wingyplus
Copy link

It would be good to see it support LINE OAuth Provider (https://developers.line.biz/en/services/line-login/). I can open PR if you're all agree.

@danschultzer
Copy link
Collaborator

That would be great!

Looks like they support OIDC which is very easy to add an integration for. You can take a look at the Azure AD integration (ignoring the tenant logic), and the docs for OIDC base integration:

https://github.com/pow-auth/assent/blob/master/lib/assent/strategies/azure_ad.ex
https://github.com/pow-auth/assent/blob/master/lib/assent/strategies/oidc/base.ex

For the tests I usually copy values from the provider documentation: https://github.com/pow-auth/assent/blob/master/test/assent/strategies/azure_ad_test.exs#L6

@wingyplus
Copy link
Author

@danschultzer Thanks for your inform. I'll read and open PR today. :)

@wingyplus
Copy link
Author

wingyplus commented Oct 15, 2020

@danschultzer LINE Login use HS256 for ID Token. How do we change alg to use HS256 instead of RS256?

@danschultzer since LINE Login use alg HS256 for ID Token. After I try passing params to the callback I received error like this:

{:error, "`alg` in ID Token can only be \"RS256\""}

After read and inspecting code. I found that error come from OIDC.validate_id_token/2 in step verify_alg/2 after passing verify_jwt/3 which's returns alg HS256 in the header. Is it should be check HS256 in verify_alg/2 or need another option to make it work on HS256?

@wingyplus
Copy link
Author

wingyplus commented Oct 15, 2020

It's work fine if we set id_token_signed_response_alg in openid_configuration but it's requires another configuration to make it works. This is sample configuration that it's works for me:

  def default_config(_config) do
    [
      site: "https://access.line.me",
      authorization_params: [scope: "email profile", response_type: "code"],
      openid_configuration: %{
        "id_token_signed_response_alg" => ["HS256"],
        "issuer" => "https://access.line.me",
        "authorization_endpoint" => "https://access.line.me/oauth2/v2.1/authorize",
        "token_endpoint" => "https://api.line.me/oauth2/v2.1/token",
        "jwks_uri" => "https://api.line.me/oauth2/v2.1/certs"
      }
    ]
  end

I need to set this manually because well known openid configuration doesn't returned id_token_signed_response_alg:

$ curl https://access.line.me/.well-known/openid-configuration
{
  "issuer": "https://access.line.me",
  "authorization_endpoint": "https://access.line.me/oauth2/v2.1/authorize",
  "token_endpoint": "https://api.line.me/oauth2/v2.1/token",
  "jwks_uri": "https://api.line.me/oauth2/v2.1/certs",
  "response_types_supported": [ "code" ],
  "subject_types_supported": [ "pairwise" ],
  "id_token_signing_alg_values_supported": [ "ES256" ]
}

Do you have any suggestion?

wingyplus pushed a commit to wingyplus/assent that referenced this issue Oct 15, 2020
Add default LINE Login OpenID Connect configuration. The openid configuration
dump from /.well-known/openid-configuration plus `id_token_signed_response_alg`
to make it work on ID Token with alg HS256.

Closes pow-auth#57
wingyplus pushed a commit to wingyplus/assent that referenced this issue Oct 15, 2020
Add default LINE Login OpenID Connect configuration. The openid configuration
dump from /.well-known/openid-configuration plus `id_token_signed_response_alg`
to make it work on ID Token with alg HS256.

Closes pow-auth#57
wingyplus pushed a commit to wingyplus/assent that referenced this issue Oct 15, 2020
Add default LINE Login OpenID Connect configuration. The openid configuration
dump from /.well-known/openid-configuration plus `id_token_signed_response_alg`
to make it work on ID Token with alg HS256.

Closes pow-auth#57
danschultzer pushed a commit to wingyplus/assent that referenced this issue Oct 18, 2020
Add default LINE Login OpenID Connect configuration. The openid configuration
dump from /.well-known/openid-configuration plus `id_token_signed_response_alg`
to make it work on ID Token with alg HS256.

Closes pow-auth#57
@danschultzer
Copy link
Collaborator

Yeah, found out the handling of the response alg was incorrect. It was a bit difficult to understand from the RFC:

  1. The alg value SHOULD be the default of RS256 or the algorithm sent by the Client in the id_token_signed_response_alg parameter during Registration.

But I looked at other OIDC implementations, and setting it as a configuration option seems to be the way to do it. #59 handles that, and I've refactored #58 to use the new configuration option so we don't need to set the open id config manually. I'll get a new release out shortly!

mitcheaton1 pushed a commit to goaero/assent that referenced this issue Jul 13, 2021
Add default LINE Login OpenID Connect configuration. The openid configuration
dump from /.well-known/openid-configuration plus `id_token_signed_response_alg`
to make it work on ID Token with alg HS256.

Closes pow-auth#57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants