File tree 5 files changed +13
-4
lines changed
packages/oauth-providers/src/providers
5 files changed +13
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @hono/oauth-providers ' : minor
3
+ ---
4
+
5
+ Add availbility to pass parameter state into OAuth middlewares
Original file line number Diff line number Diff line change @@ -12,10 +12,11 @@ export function facebookAuth(options: {
12
12
fields : Fields [ ]
13
13
client_id ?: string
14
14
client_secret ?: string
15
+ state ?: string
15
16
redirect_uri ?: string
16
17
} ) : MiddlewareHandler {
17
18
return async ( c , next ) => {
18
- const newState = getRandomState ( )
19
+ const newState = options . state || getRandomState ( )
19
20
// Create new Auth instance
20
21
const auth = new AuthFlow ( {
21
22
client_id : options . client_id || ( env ( c ) . FACEBOOK_ID as string ) ,
Original file line number Diff line number Diff line change @@ -12,10 +12,11 @@ export function githubAuth(options: {
12
12
client_secret ?: string
13
13
scope ?: GitHubScope [ ]
14
14
oauthApp ?: boolean
15
+ state ?: string
15
16
redirect_uri ?: string
16
17
} ) : MiddlewareHandler {
17
18
return async ( c , next ) => {
18
- const newState = getRandomState ( )
19
+ const newState = options . state || getRandomState ( )
19
20
// Create new Auth instance
20
21
const auth = new AuthFlow ( {
21
22
client_id : options . client_id || ( env ( c ) . GITHUB_ID as string ) ,
Original file line number Diff line number Diff line change @@ -12,10 +12,11 @@ export function linkedinAuth(options: {
12
12
client_secret ?: string
13
13
scope ?: LinkedInScope [ ]
14
14
appAuth ?: boolean
15
+ state ?: string
15
16
redirect_uri ?: string
16
17
} ) : MiddlewareHandler {
17
18
return async ( c , next ) => {
18
- const newState = getRandomState ( )
19
+ const newState = options . state || getRandomState ( )
19
20
// Create new Auth instance
20
21
const auth = new AuthFlow ( {
21
22
client_id : options . client_id || ( env ( c ) . LINKEDIN_ID as string ) ,
Original file line number Diff line number Diff line change @@ -13,11 +13,12 @@ export function xAuth(options: {
13
13
fields ?: XFields [ ]
14
14
client_id ?: string
15
15
client_secret ?: string
16
+ state ?: string
16
17
redirect_uri ?: string
17
18
} ) : MiddlewareHandler {
18
19
return async ( c , next ) => {
19
20
// Generate encoded "keys"
20
- const newState = getRandomState ( )
21
+ const newState = options . state || getRandomState ( )
21
22
const challenge = await getCodeChallenge ( )
22
23
23
24
const auth = new AuthFlow ( {
You can’t perform that action at this time.
0 commit comments