Skip to content

Commit 729effd

Browse files
Jack-R-Hongaeneasralnr
authored
feat: add support for Line v2.1 OIDC provider (#4240)
For OIDC Line Login, you only need to add id_token_key_type=JWK in the exchange step to issue tokens in ES256 format. #1116 --------- Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Arne Luenser <arne.luenser@ory.sh>
1 parent 18755fe commit 729effd

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

embedx/config.schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@
510510
"netid",
511511
"dingtalk",
512512
"patreon",
513+
"line",
513514
"linkedin",
514515
"linkedin_v2",
515516
"lark",

selfservice/strategy/oidc/provider_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ var supportedProviders = map[string]func(config *Configuration, reg Dependencies
186186
"patreon": NewProviderPatreon,
187187
"lark": NewProviderLark,
188188
"x": NewProviderX,
189+
"line": NewProviderLineV21,
189190
"jackson": NewProviderJackson,
190191
"fedcm-test": NewProviderTestFedcm,
191192
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright © 2024 Ory Corp
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package oidc
5+
6+
import (
7+
"context"
8+
9+
"golang.org/x/oauth2"
10+
)
11+
12+
type ProviderLineV21 struct {
13+
*ProviderGenericOIDC
14+
}
15+
16+
func NewProviderLineV21(
17+
config *Configuration,
18+
reg Dependencies,
19+
) Provider {
20+
return &ProviderLineV21{
21+
&ProviderGenericOIDC{
22+
config: config,
23+
reg: reg,
24+
},
25+
}
26+
}
27+
28+
func (g *ProviderLineV21) Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error) {
29+
o, err := g.ProviderGenericOIDC.OAuth2(ctx)
30+
31+
if err != nil {
32+
return nil, err
33+
}
34+
// Line login requires adding id_token_key_type=JWK when getting the token in order to issue an HS256 token.
35+
opts = append(opts, oauth2.SetAuthURLParam("id_token_key_type", "JWK"))
36+
37+
token, err := o.Exchange(ctx, code, opts...)
38+
39+
return token, err
40+
41+
}

selfservice/strategy/oidc/provider_private_net_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func TestProviderPrivateIP(t *testing.T) {
8686
// Yandex uses a fixed token URL and does not use the issuer.
8787
// NetID uses a fixed token URL and does not use the issuer.
8888
// X uses a fixed token URL and userinfoRL and does not use the issuer value.
89+
// Line v2.1 uses a fixed token URL and does not use the issuer.
8990
} {
9091
t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
9192
p := tc.p(tc.c)

0 commit comments

Comments
 (0)