Skip to content

Commit 4887eb6

Browse files
bjellinerubenmoya
authored andcommitted
add one line to configuration
1 parent 87094df commit 4887eb6

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
[![NPM version](https://img.shields.io/npm/v/adonis-ally-gitlab.svg)](https://www.npmjs.com/package/adonis-ally-gitlab)
44

5-
A [Gitlab](https://gitlab.com/) driver for [AdonisJS Ally](https://docs.adonisjs.com/guides/auth/social)
5+
A [Gitlab](https://gitlab.com/) driver for [AdonisJS Ally](https://docs.adonisjs.com/guides/auth/social).
6+
You can authenticate with your self hosted gitlab or with https://gitlab.com/
67

78
## Getting started
89

@@ -29,6 +30,7 @@ node ace configure adonis-ally-gitlab
2930
### 3. Validate environment variables
3031

3132
```ts
33+
GITLAB_URL: Env.schema.string(),
3234
GITLAB_CLIENT_ID: Env.schema.string(),
3335
GITLAB_CLIENT_SECRET: Env.schema.string(),
3436
```
@@ -40,16 +42,22 @@ const allyConfig: AllyConfig = {
4042
// ... other drivers
4143
gitlab: {
4244
driver: 'gitlab',
45+
gitlabUrl: 'https://gitlab.example.com/'
4346
clientId: Env.get('GITLAB_CLIENT_ID'),
4447
clientSecret: Env.get('GITLAB_CLIENT_SECRET'),
4548
callbackUrl: 'http://localhost:3333/gitlab/callback',
4649
},
4750
}
4851
```
4952

53+
If you don't supply gitlabUrl, https.//www.gitlab.com/ will be used.
54+
55+
When using self hosted gitlab,
56+
get the clientId and clientSecret from /admin/applications/ on your gitlab instance.
57+
5058
## Scopes
5159

52-
You can pass an array of scopes in your configuration, for example `['user', 'profile', 'api']`. You have a full list of scopes in the [Gitlab Oauth documentation](https://docs.gitlab.com/ee/integration/oauth_provider.html#authorized-applications)
60+
You can pass an array of scopes in your configuration, for example `['read_user', 'profile', 'api']`. You have a full list of scopes in the [Gitlab Oauth documentation](https://docs.gitlab.com/ee/integration/oauth_provider.html#authorized-applications)
5361

5462
## How it works
5563

src/Gitlab/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type GitlabScopes =
2727

2828
export type GitlabDriverConfig = {
2929
driver: 'gitlab'
30+
gitlabUrl?: string
3031
clientId: string
3132
clientSecret: string
3233
callbackUrl: string
@@ -53,7 +54,11 @@ export class GitlabDriver extends Oauth2Driver<GitlabAccessToken, GitlabScopes>
5354

5455
constructor(ctx: HttpContextContract, public config: GitlabDriverConfig) {
5556
super(ctx, config)
56-
57+
if (config.gitlabUrl) {
58+
this.authorizeUrl = config.gitlabUrl + 'oauth/authorize'
59+
this.accessTokenUrl = config.gitlabUrl + 'oauth/token'
60+
this.userInfoUrl = config.gitlabUrl + 'api/v4/user'
61+
}
5762
this.loadState()
5863
}
5964

0 commit comments

Comments
 (0)