mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
12 Commits
@auth/kyse
...
feat/matte
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58b72616a2 | ||
|
|
bd9c4b0d6a | ||
|
|
12be8355fe | ||
|
|
50209a9495 | ||
|
|
8b460e014d | ||
|
|
684e7c208c | ||
|
|
0440da324e | ||
|
|
5538430952 | ||
|
|
c8b04f66f4 | ||
|
|
d758bb2348 | ||
|
|
41b162e07c | ||
|
|
2337dd9f44 |
36
docs/docs/reference/05-oauth-providers/mattermost.md
Normal file
36
docs/docs/reference/05-oauth-providers/mattermost.md
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
id: mattermost
|
||||
title: Mattermost
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.mattermost.com/integrate/apps/authentication/oauth2
|
||||
|
||||
## Configuration
|
||||
|
||||
http://my-cool-server.cloud.mattermost.com/mycoolteam/integrations/oauth2-apps
|
||||
|
||||
## Options
|
||||
|
||||
The **Mattermost provider** comes with a set of default options:
|
||||
|
||||
- [Mattermost Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/mattermost.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import Mattermost from "@auth/core/providers/mattermost";
|
||||
...
|
||||
providers: [
|
||||
Mattermost({
|
||||
// The base url of your Mattermost instance. e.g https://my-cool-server.cloud.mattermost.com
|
||||
clientId: env.MATTERMOST_ID,
|
||||
clientSecret: env.MATTERMOST_SECRET,
|
||||
issuer: env.MATTERMOST_ISSUER,
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -87,10 +87,14 @@ export default function SigninPage(props: {
|
||||
"--provider-dark-bg": provider.style?.bgDark ?? "",
|
||||
"--provider-color": provider.style?.text ?? "",
|
||||
"--provider-dark-color": provider.style?.textDark ?? "",
|
||||
gap: 8,
|
||||
}}
|
||||
>
|
||||
{provider.style?.logo && (
|
||||
<img
|
||||
loading="lazy"
|
||||
height={24}
|
||||
width={24}
|
||||
id="provider-logo"
|
||||
src={`${
|
||||
provider.style.logo.startsWith("/") ? logos : ""
|
||||
@@ -99,6 +103,9 @@ export default function SigninPage(props: {
|
||||
)}
|
||||
{provider.style?.logoDark && (
|
||||
<img
|
||||
loading="lazy"
|
||||
height={24}
|
||||
width={24}
|
||||
id="provider-logo-dark"
|
||||
src={`${
|
||||
provider.style.logo.startsWith("/") ? logos : ""
|
||||
|
||||
91
packages/core/src/providers/mattermost.ts
Normal file
91
packages/core/src/providers/mattermost.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
import type { OAuthConfig, OAuthUserConfig } from "./oauth"
|
||||
|
||||
/** @see [Get a user](https://api.mattermost.com/#tag/users/operation/GetUser) */
|
||||
export interface MattermostProfile {
|
||||
id: string
|
||||
/** The time in milliseconds a user was created */
|
||||
create_at: number
|
||||
/** The time in milliseconds a user was last updated */
|
||||
update_at: number
|
||||
/** The time in milliseconds a user was deleted */
|
||||
delete_at: number
|
||||
username: string
|
||||
auth_data: string
|
||||
auth_service: string
|
||||
email: string
|
||||
email_verified: boolean
|
||||
nickname: string
|
||||
first_name: string
|
||||
last_name: string
|
||||
position: string
|
||||
roles: string
|
||||
notify_props: {
|
||||
/** Set to "true" to enable channel-wide notifications (@channel, @all, etc.), "false" to disable. Defaults to "true". */
|
||||
channel: string
|
||||
comments: string
|
||||
/** Set to "all" to receive desktop notifications for all activity, "mention" for mentions and direct messages only, and "none" to disable. Defaults to "all". */
|
||||
desktop: string
|
||||
/** Set to "true" to enable sound on desktop notifications, "false" to disable. Defaults to "true". */
|
||||
desktop_sound: string
|
||||
desktop_threads: string
|
||||
/** Set to "true" to enable email notifications, "false" to disable. Defaults to "true". */
|
||||
email: string
|
||||
email_threads: string
|
||||
/** Set to "true" to enable mentions for first name. Defaults to "true" if a first name is set, "false" otherwise. */
|
||||
first_name: string
|
||||
/** A comma-separated list of words to count as mentions. Defaults to username and @username. */
|
||||
mention_keys: string
|
||||
/** Set to "all" to receive push notifications for all activity, "mention" for mentions and direct messages only, and "none" to disable. Defaults to "mention". */
|
||||
push: string
|
||||
push_status: string
|
||||
push_threads: string
|
||||
}
|
||||
last_password_update: number
|
||||
locale: string
|
||||
timezone: {
|
||||
/** This value is set automatically when the "useAutomaticTimezone" is set to "true". */
|
||||
automaticTimezone: string
|
||||
/** Value when setting manually the timezone, i.e. "Europe/Berlin". */
|
||||
manualTimezone: string
|
||||
/** Set to "true" to use the browser/system timezone, "false" to set manually. Defaults to "true". */
|
||||
useAutomaticTimezone: string
|
||||
}
|
||||
disable_welcome_email: boolean
|
||||
/** ID of accepted terms of service, if any. This field is not present if empty. */
|
||||
terms_of_service_id?: string
|
||||
/** The time in milliseconds the user accepted the terms of service */
|
||||
terms_of_service_create_at?: number
|
||||
}
|
||||
|
||||
export default function Mattermost<P extends MattermostProfile>(
|
||||
config: OAuthUserConfig<P> & { issuer: string }
|
||||
): OAuthConfig<P> {
|
||||
const { issuer, ...rest } = config
|
||||
|
||||
return {
|
||||
id: "mattermost",
|
||||
name: "Mattermost",
|
||||
type: "oauth",
|
||||
client: { token_endpoint_auth_method: "client_secret_post" },
|
||||
token: `${issuer}/oauth/access_token`,
|
||||
authorization: `${issuer}/oauth/authorize`,
|
||||
userinfo: `${issuer}/api/v4/users/me`,
|
||||
profile(profile) {
|
||||
return {
|
||||
id: profile.id,
|
||||
name: profile.username ?? `${profile.first_name} ${profile.last_name}`,
|
||||
email: profile.email,
|
||||
image: null,
|
||||
}
|
||||
},
|
||||
style: {
|
||||
logo: "/mattermost.svg",
|
||||
logoDark: "/mattermost-dark.svg",
|
||||
bg: "#fff",
|
||||
text: "#000",
|
||||
bgDark: "#000",
|
||||
textDark: "#fff",
|
||||
},
|
||||
options: rest,
|
||||
}
|
||||
}
|
||||
4
packages/next-auth/provider-logos/mattermost-dark.svg
Normal file
4
packages/next-auth/provider-logos/mattermost-dark.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg width="700" height="700" viewBox="0 0 700 700" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M496.909 147.716L499.54 200.779C542.559 248.303 559.539 315.609 538.125 378.865C506.159 473.292 400.753 522.93 302.694 489.735C204.635 456.54 151.057 353.081 183.023 258.653C204.508 195.186 259.171 151.953 322.48 140.505L356.685 100.091C249.969 97.2018 149.288 163.442 113.265 269.853C69.0048 400.598 139.114 542.468 269.859 586.729C400.604 630.99 542.474 560.88 586.735 430.135C622.7 323.895 583.148 210.308 496.909 147.716Z" fill="#dddddd"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M435.623 304.289L433.812 230.109L432.359 187.424L431.376 150.444C431.376 150.444 431.581 132.612 430.959 128.422C430.828 127.54 430.551 126.822 430.221 126.196C430.18 126.108 430.141 126.02 430.096 125.934C430.049 125.854 430.003 125.78 429.954 125.705C429.27 124.528 428.195 123.572 426.804 123.101C425.381 122.619 423.909 122.738 422.631 123.29C422.604 123.3 422.579 123.309 422.552 123.32C422.4 123.388 422.255 123.465 422.109 123.546C421.503 123.841 420.887 124.223 420.284 124.808C417.244 127.758 406.575 142.048 406.575 142.048L383.331 170.826L356.248 203.851L309.749 261.677C309.749 261.677 288.411 288.308 293.126 321.088C297.841 353.868 322.211 369.837 341.117 376.238C360.023 382.638 389.082 384.756 412.74 361.581C436.396 338.405 435.623 304.289 435.623 304.289Z" fill="#dddddd"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
4
packages/next-auth/provider-logos/mattermost.svg
Normal file
4
packages/next-auth/provider-logos/mattermost.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg width="700" height="700" viewBox="0 0 700 700" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M496.909 147.716L499.54 200.779C542.559 248.303 559.539 315.609 538.125 378.865C506.159 473.292 400.753 522.93 302.694 489.735C204.635 456.54 151.057 353.081 183.023 258.653C204.508 195.186 259.171 151.953 322.48 140.505L356.685 100.091C249.969 97.2018 149.288 163.442 113.265 269.853C69.0048 400.598 139.114 542.468 269.859 586.729C400.604 630.99 542.474 560.88 586.735 430.135C622.7 323.895 583.148 210.308 496.909 147.716Z" fill="#222222"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M435.623 304.289L433.812 230.109L432.359 187.424L431.376 150.444C431.376 150.444 431.581 132.612 430.959 128.422C430.828 127.54 430.551 126.822 430.221 126.196C430.18 126.108 430.141 126.02 430.096 125.934C430.049 125.854 430.003 125.78 429.954 125.705C429.27 124.528 428.195 123.572 426.804 123.101C425.381 122.619 423.909 122.738 422.631 123.29C422.604 123.3 422.579 123.309 422.552 123.32C422.4 123.388 422.255 123.465 422.109 123.546C421.503 123.841 420.887 124.223 420.284 124.808C417.244 127.758 406.575 142.048 406.575 142.048L383.331 170.826L356.248 203.851L309.749 261.677C309.749 261.677 288.411 288.308 293.126 321.088C297.841 353.868 322.211 369.837 341.117 376.238C360.023 382.638 389.082 384.756 412.74 361.581C436.396 338.405 435.623 304.289 435.623 304.289Z" fill="#222222"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user