Skip to content

Commit

Permalink
Adding Microsoft adapter (#74)
Browse files Browse the repository at this point in the history
* Added microsoft adapter

* Added MicrosoftConfig interface
  • Loading branch information
bjorntechTobbe authored Dec 14, 2024
1 parent 39160f8 commit 422be1d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/openauth/src/adapter/microsoft.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Oauth2Adapter, Oauth2WrappedConfig } from "./oauth2.js"
import { OidcAdapter, OidcWrappedConfig } from "./oidc.js"

export interface MicrosoftConfig extends Oauth2WrappedConfig {
tenant: string
}

export function MicrosoftAdapter(config: MicrosoftConfig) {
return Oauth2Adapter({
...config,
type: "microsoft",
endpoint: {
authorization: `https://login.microsoftonline.com/${config?.tenant}/oauth2/v2.0/authorize`,
token: `https://login.microsoftonline.com/${config?.tenant}/oauth2/v2.0/token`,
},
})
}

export function MicrosoftOidcAdapter(config: OidcWrappedConfig) {
return OidcAdapter({
...config,
type: "microsoft",
issuer: "https://graph.microsoft.com/oidc/userinfo",
})
}

0 comments on commit 422be1d

Please sign in to comment.