File tree 4 files changed +243
-0
lines changed
packages/next-auth/src/providers
4 files changed +243
-0
lines changed Original file line number Diff line number Diff line change @@ -50,3 +50,6 @@ DATABASE_URL=
50
50
BOXYHQSAML_ISSUER="https://jackson-demo.boxyhq.com"
51
51
BOXYHQSAML_ID="tenant=boxyhq.com&product=saml-demo.boxyhq.com"
52
52
BOXYHQSAML_SECRET="dummy"
53
+
54
+ WIKIMEDIA_ID=
55
+ WIKIMEDIA_SECRET=
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import PatreonProvider from "next-auth/providers/patreon"
32
32
import TraktProvider from "next-auth/providers/trakt"
33
33
import WorkOSProvider from "next-auth/providers/workos"
34
34
import BoxyHQSAMLProvider from "next-auth/providers/boxyhq-saml"
35
+ import WikimediaProvider from "next-auth/providers/wikimedia"
35
36
36
37
// TypeORM
37
38
import { TypeORMLegacyAdapter } from "@next-auth/typeorm-legacy-adapter"
@@ -229,6 +230,10 @@ export const authOptions: NextAuthOptions = {
229
230
clientId : process . env . BOXYHQSAML_ID ,
230
231
clientSecret : process . env . BOXYHQSAML_SECRET ,
231
232
} ) ,
233
+ WikimediaProvider ( {
234
+ clientId : process . env . WIKIMEDIA_ID ,
235
+ clientSecret : process . env . WIKIMEDIA_SECRET ,
236
+ } ) ,
232
237
] ,
233
238
debug : true ,
234
239
theme : {
Original file line number Diff line number Diff line change
1
+ ---
2
+ id : wikimedia
3
+ title : Wikimedia
4
+ ---
5
+
6
+ ## Documentation
7
+
8
+ https://www.mediawiki.org/wiki/Extension:OAuth
9
+
10
+ This provider also supports all Wikimedia projects:
11
+
12
+ - Wikipedia
13
+ - Wikidata
14
+ - Wikibooks
15
+ - Wiktionary
16
+ - etc..
17
+
18
+ Please be aware that Wikimedia accounts do not have to have an associated email address. So you may want to add check if the user has an email address before allowing them to login.
19
+
20
+ ## Configuration
21
+
22
+ 1 . Go to and accept the Consumer Registration doc: https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration
23
+ 2 . Request a new OAuth 2.0 consumer to get the ` clientId ` and ` clientSecret ` : https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oauth2
24
+ 2a. Add the following redirect URL into the console ` http://<your-next-app-url>/api/auth/callback/wikimedia `
25
+ 2b. Do not check the box next to ` This consumer is only for [your username] `
26
+ 2c. Unless you explicitly need a larger scope, feel free to select the radio button labelled ` User identity verification only - no ability to read pages or act on the users behalf. `
27
+
28
+ After registration, you can initally test your application only with your own Wikimedia account. You may have to wait several days for the application to be approved for it to be used by everyone.
29
+
30
+ ## Options
31
+
32
+ The ** Wikimedia Provider** comes with a set of default options:
33
+
34
+ - [ Wikimedia Provider options] ( https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/wikimedia.ts )
35
+
36
+ You can override any of the options to suit your own use case.
37
+
38
+ ## Example
39
+
40
+ ``` js
41
+ import WikimediaProvider from " next-auth/providers/wikimedia" ;
42
+ ...
43
+ providers: [
44
+ WikimediaProvider ({
45
+ clientId: process .env .WIKIMEDIA_CLIENT_ID ,
46
+ clientSecret: process .env .WIKIMEDIA_CLIENT_SECRET
47
+ })
48
+ ]
49
+ ...
50
+ ```
Original file line number Diff line number Diff line change
1
+ import type { OAuthConfig , OAuthUserConfig } from "."
2
+
3
+ export type WikimediaGroup =
4
+ | "*"
5
+ | "user"
6
+ | "autoconfirmed"
7
+ | "extendedconfirmed"
8
+ | "bot"
9
+ | "sysop"
10
+ | "bureaucrat"
11
+ | "steward"
12
+ | "accountcreator"
13
+ | "import"
14
+ | "transwiki"
15
+ | "ipblock-exempt"
16
+ | "oversight"
17
+ | "rollbacker"
18
+ | "propertycreator"
19
+ | "wikidata-staff"
20
+ | "flood"
21
+ | "translationadmin"
22
+ | "confirmed"
23
+ | "flow-bot"
24
+ | "checkuser"
25
+
26
+ export type WikimediaGrant =
27
+ | "basic"
28
+ | "blockusers"
29
+ | "checkuser"
30
+ | "createaccount"
31
+ | "delete"
32
+ | "editinterface"
33
+ | "editmycssjs"
34
+ | "editmyoptions"
35
+ | "editmywatchlist"
36
+ | "editpage"
37
+ | "editprotected"
38
+ | "editsiteconfig"
39
+ | "globalblock"
40
+ | "highvolume"
41
+ | "import"
42
+ | "mergehistory"
43
+ | "oath"
44
+ | "oversight"
45
+ | "patrol"
46
+ | "privateinfo"
47
+ | "protect"
48
+ | "rollback"
49
+ | "sendemail"
50
+ | "shortenurls"
51
+ | "uploadfile"
52
+ | "viewdeleted"
53
+ | "viewmywatchlist"
54
+
55
+ export type WikimediaRight =
56
+ | "abusefilter-log"
57
+ | "apihighlimits"
58
+ | "applychangetags"
59
+ | "autoconfirmed"
60
+ | "autopatrol"
61
+ | "autoreview"
62
+ | "bigdelete"
63
+ | "block"
64
+ | "blockemail"
65
+ | "bot"
66
+ | "browsearchive"
67
+ | "changetags"
68
+ | "checkuser"
69
+ | "checkuser-log"
70
+ | "createaccount"
71
+ | "createpage"
72
+ | "createpagemainns"
73
+ | "createtalk"
74
+ | "delete"
75
+ | "delete-redirect"
76
+ | "deletedhistory"
77
+ | "deletedtext"
78
+ | "deletelogentry"
79
+ | "deleterevision"
80
+ | "edit"
81
+ | "edit-legal"
82
+ | "editinterface"
83
+ | "editmyoptions"
84
+ | "editmyusercss"
85
+ | "editmyuserjs"
86
+ | "editmyuserjson"
87
+ | "editmywatchlist"
88
+ | "editprotected"
89
+ | "editsemiprotected"
90
+ | "editsitecss"
91
+ | "editsitejs"
92
+ | "editsitejson"
93
+ | "editusercss"
94
+ | "edituserjs"
95
+ | "edituserjson"
96
+ | "globalblock"
97
+ | "import"
98
+ | "importupload"
99
+ | "ipblock-exempt"
100
+ | "item-merge"
101
+ | "item-redirect"
102
+ | "item-term"
103
+ | "markbotedits"
104
+ | "massmessage"
105
+ | "mergehistory"
106
+ | "minoredit"
107
+ | "move"
108
+ | "move-subpages"
109
+ | "movefile"
110
+ | "movestable"
111
+ | "mwoauth-authonlyprivate"
112
+ | "nominornewtalk"
113
+ | "noratelimit"
114
+ | "nuke"
115
+ | "patrol"
116
+ | "patrolmarks"
117
+ | "property-create"
118
+ | "property-term"
119
+ | "protect"
120
+ | "purge"
121
+ | "read"
122
+ | "reupload"
123
+ | "reupload-own"
124
+ | "reupload-shared"
125
+ | "rollback"
126
+ | "sendemail"
127
+ | "skipcaptcha"
128
+ | "suppressionlog"
129
+ | "tboverride"
130
+ | "templateeditor"
131
+ | "torunblocked"
132
+ | "transcode-reset"
133
+ | "translate"
134
+ | "undelete"
135
+ | "unwatchedpages"
136
+ | "upload"
137
+ | "upload_by_url"
138
+ | "viewmywatchlist"
139
+ | "viewsuppressed"
140
+ | "writeapi"
141
+
142
+ export interface WikimediaProfile extends Record < string , any > {
143
+ sub : string
144
+ username : string
145
+ editcount : number
146
+ confirmed_email : boolean
147
+ blocked : boolean
148
+ registered : string
149
+ groups : WikimediaGroup [ ]
150
+ rights : WikimediaRight [ ]
151
+ grants : WikimediaGrant [ ]
152
+ realname : string
153
+ email : string
154
+ }
155
+
156
+ /**
157
+ * Wikimedia OAuth2 provider.
158
+ * All Wikimedia wikis are supported. Wikipedia, Wikidata, etc...
159
+ *
160
+ * (Register)[https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration]
161
+ * (Documentation)[https://www.mediawiki.org/wiki/Extension:OAuth]
162
+ */
163
+ export default function Wikimedia < P extends WikimediaProfile > (
164
+ options : OAuthUserConfig < P >
165
+ ) : OAuthConfig < P > {
166
+ return {
167
+ id : "wikimedia" ,
168
+ name : "Wikimedia" ,
169
+ type : "oauth" ,
170
+ token : "https://meta.wikimedia.org/w/rest.php/oauth2/access_token" ,
171
+ userinfo : "https://meta.wikimedia.org/w/rest.php/oauth2/resource/profile" ,
172
+ authorization : {
173
+ url : "https://meta.wikimedia.org/w/rest.php/oauth2/authorize" ,
174
+ params : { scope : "" } ,
175
+ } ,
176
+ profile ( profile ) {
177
+ return {
178
+ id : profile . sub ,
179
+ name : profile . username ,
180
+ email : profile . email ,
181
+ }
182
+ } ,
183
+ options,
184
+ }
185
+ }
You can’t perform that action at this time.
1 commit comments
vercel[bot] commentedon Jul 10, 2022
Successfully deployed to the following URLs:
next-auth – ./
next-auth.js.org
next-auth-nextauthjs.vercel.app
next-auth-git-main-nextauthjs.vercel.app
www.next-auth.js.org
next-auth-phi-two.vercel.app