Skip to content

Commit

Permalink
feat(authentication-service): facebook oauth added (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutosh-bansal-2136 authored Jul 12, 2021
1 parent b967ee7 commit 3c3cae8
Show file tree
Hide file tree
Showing 28 changed files with 9,078 additions and 95,553 deletions.
8,326 changes: 16 additions & 8,310 deletions sandbox/audit-ms-example/package-lock.json

Large diffs are not rendered by default.

9,017 changes: 16 additions & 9,001 deletions sandbox/auth-ms-basic-example/package-lock.json

Large diffs are not rendered by default.

9,544 changes: 16 additions & 9,528 deletions sandbox/auth-multitenant-example/package-lock.json

Large diffs are not rendered by default.

9,488 changes: 17 additions & 9,471 deletions services/audit-service/package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions services/authentication-service/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ APPLE_AUTH_CLIENT_ID=a
APPLE_AUTH_TEAM_ID=q
APPLE_AUTH_KEY_ID=q
APPLE_AUTH_CALLBACK_URL=q
FACEBOOK_AUTH_URL=q
FACEBOOK_AUTH_CLIENT_ID=a
FACEBOOK_AUTH_CLIENT_SECRET=q
FACEBOOK_AUTH_TOKEN_URL=q
FACEBOOK_AUTH_CALLBACK_URL=q
REDIS_PORT=a
REDIS_HOST=a
REDIS_URL=
Expand Down
5 changes: 5 additions & 0 deletions services/authentication-service/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ APPLE_AUTH_CLIENT_ID=
APPLE_AUTH_TEAM_ID=
APPLE_AUTH_KEY_ID=
APPLE_AUTH_CALLBACK_URL=
FACEBOOK_AUTH_URL=
FACEBOOK_AUTH_CLIENT_ID=
FACEBOOK_AUTH_CLIENT_SECRET=
FACEBOOK_AUTH_TOKEN_URL=
FACEBOOK_AUTH_CALLBACK_URL=
FORGOT_PASSWORD_LINK_EXPIRY=
KEYCLOAK_HOST=
KEYCLOAK_REALM=
Expand Down
10 changes: 10 additions & 0 deletions services/authentication-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ export class Client extends BootMixin(
| `APPLE_AUTH_TEAM_ID` | N | | Apple team id for the service |
| `APPLE_AUTH_KEY_ID` | N | | Apple key id for the service |
| `APPLE_AUTH_CALLBACK_URL` | N | | Apple callback URL for the client configuration in Apple |
| `INSTAGRAM_AUTH_URL` | N | | Instagram OAuth2.0 authorization URL if authentication strategy is set to Instagram |
| `INSTAGRAM_AUTH_CLIENT_ID` | N | | Instagram client ID for the service |
| `INSTAGRAM_AUTH_CLIENT_SECRET`| N | | Instagram client secret for the service |
| `INSTAGRAM_AUTH_TOKEN_URL` | N | | Instagram OAuth2.0 authorization URL if authentication strategy is set to Instagram |
| `INSTAGRAM_AUTH_CALLBACK_URL` | N | | Instagram callback URL for the client configuration in Instagram |
| `FACEBOOK_AUTH_URL` | N | | Facebook OAuth2.0 authorization URL if authentication strategy is set to Facebook |
| `FACEBOOK_AUTH_CLIENT_ID` | N | | Facebook client ID for the service |
| `FACEBOOK_AUTH_CLIENT_SECRET` | N | | Facebook client secret for the service |
| `FACEBOOK_AUTH_TOKEN_URL` | N | | Facebook OAuth2.0 authorization URL if authentication strategy is set to Facebook |
| `FACEBOOK_AUTH_CALLBACK_URL` | N | | Facebook callback URL for the client configuration in Facebook |
| `FORGOT_PASSWORD_LINK_EXPIRY` | N | 1800 | Expiration period of temporary password in seconds. 1800 seconds (30 minutes) is the default. |
| `KEYCLOAK_HOST` | N | | Hostname of the Keycloak instance |
| `KEYCLOAK_REALM` | N | | Realm (tenant) in Keycloak |
Expand Down
69 changes: 69 additions & 0 deletions services/authentication-service/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,75 @@
"operationId": "LoginController.resetPassword"
}
},
"/auth/facebook": {
"post": {
"x-controller-name": "LoginController",
"x-operation-name": "postLoginViaFacebook",
"tags": [
"LoginController"
],
"responses": {
"200": {
"description": "POST Call for Facebook based login",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TokenResponse"
}
}
}
}
},
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "#/components/schemas/ClientAuthRequest"
}
}
}
},
"operationId": "LoginController.postLoginViaFacebook"
}
},
"/auth/facebook-auth-redirect": {
"get": {
"x-controller-name": "LoginController",
"x-operation-name": "facebookCallback",
"tags": [
"LoginController"
],
"responses": {
"200": {
"description": "Facebook Redirect Token Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TokenResponse"
}
}
}
}
},
"parameters": [
{
"name": "code",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "state",
"in": "query",
"schema": {
"type": "string"
}
}
],
"operationId": "LoginController.facebookCallback"
}
},
"/auth/forget-password": {
"post": {
"x-controller-name": "ForgetPasswordController",
Expand Down
173 changes: 173 additions & 0 deletions services/authentication-service/openapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,179 @@ To perform this operation, you must be authenticated by means of one of the foll
HTTPBearer
</aside>

## LoginController.postLoginViaFacebook

<a id="opIdLoginController.postLoginViaFacebook"></a>

> Code samples
```javascript
const inputBody = '{
"client_id": "string",
"client_secret": "string"
}';
const headers = {
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'application/json'
};

fetch('/auth/facebook',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});

```

```javascript--nodejs
const fetch = require('node-fetch');
const inputBody = {
"client_id": "string",
"client_secret": "string"
};
const headers = {
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'application/json'
};
fetch('/auth/facebook',
{
method: 'POST',
body: JSON.stringify(inputBody),
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
```

`POST /auth/facebook`

> Body parameter
```yaml
client_id: string
client_secret: string

```
<h3 id="logincontroller.postloginviafacebook-parameters">Parameters</h3>
|Name|In|Type|Required|Description|
|---|---|---|---|---|
|body|body|[ClientAuthRequest](#schemaclientauthrequest)|false|none|
> Example responses
> 200 Response
```json
{
"accessToken": "string",
"refreshToken": "string",
"expires": 0,
"pubnubToken": "string"
}
```

<h3 id="logincontroller.postloginviafacebook-responses">Responses</h3>

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|POST Call for Facebook based login|[TokenResponse](#schematokenresponse)|

<aside class="success">
This operation does not require authentication
</aside>

## LoginController.facebookCallback

<a id="opIdLoginController.facebookCallback"></a>

> Code samples
```javascript

const headers = {
'Accept':'application/json'
};

fetch('/auth/facebook-auth-redirect',
{
method: 'GET',

headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});

```

```javascript--nodejs
const fetch = require('node-fetch');
const headers = {
'Accept':'application/json'
};
fetch('/auth/facebook-auth-redirect',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
```

`GET /auth/facebook-auth-redirect`

<h3 id="logincontroller.facebookcallback-parameters">Parameters</h3>

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|code|query|string|false|none|
|state|query|string|false|none|

> Example responses
> 200 Response
```json
{
"accessToken": "string",
"refreshToken": "string",
"expires": 0,
"pubnubToken": "string"
}
```

<h3 id="logincontroller.facebookcallback-responses">Responses</h3>

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Facebook Redirect Token Response|[TokenResponse](#schematokenresponse)|

<aside class="success">
This operation does not require authentication
</aside>

## LoginController.postLoginViaGoogle

<a id="opIdLoginController.postLoginViaGoogle"></a>
Expand Down
Loading

0 comments on commit 3c3cae8

Please sign in to comment.