authentication-zero 2.9.0 → 2.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/authentication-zero-api.md +210 -0
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/authentication_generator.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 349df436a5358765a5f4537e5e37e79c566dfe575875f77380fe1a2eeb21096f
|
4
|
+
data.tar.gz: f017571edaa6c887bcdecf4ffa023cc7d86830e0fba4ba3c7ad6dbd8626bf952
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a70ba5553accd5f23b71ad58b58dd270f78636b28bca944decb062d16a31d83808a9dca86cd2b38f5f83317a6748c32ef25d3944613686ea215c05cdcc647dbe
|
7
|
+
data.tar.gz: 2506decfeaa1e126d0160d11d787577ecff6c8afa6b4a27930a01ac65b9cfca2fa7ccdc82392dc488dafee102ebe4419ce1422450400810efcf7437fe1578454
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -22,6 +22,7 @@ The purpose of authentication zero is to generate a pre-built authentication sys
|
|
22
22
|
- Manage multiple sessions & devices
|
23
23
|
- Activity log (--trackable)
|
24
24
|
- Log out
|
25
|
+
- [API documentation](https://github.com/lazaronixon/authentication-zero/blob/master/authentication-zero-api.md)
|
25
26
|
|
26
27
|
## Security and best practices
|
27
28
|
|
@@ -74,6 +75,10 @@ Add these lines to your `app/views/home/index.html.erb`:
|
|
74
75
|
<%= link_to "Devices & Sessions", sessions_path %>
|
75
76
|
</div>
|
76
77
|
|
78
|
+
<div>
|
79
|
+
<%# link_to "Activity Log", authentications_events_path %>
|
80
|
+
</div>
|
81
|
+
|
77
82
|
<br>
|
78
83
|
|
79
84
|
<%= button_to "Log out", Current.session, method: :delete %>
|
@@ -0,0 +1,210 @@
|
|
1
|
+
# Authentication Zero API
|
2
|
+
|
3
|
+
This document describe the api endpoints available in authentication-zero.
|
4
|
+
|
5
|
+
## Making a request
|
6
|
+
|
7
|
+
To make a sign in request for example, append sign_in to the base URL to form something like http://localhost:3000/sign_in, also notice you have to include the Content-Type header and the JSON data: In cURL, it looks like this:
|
8
|
+
|
9
|
+
``` shell
|
10
|
+
curl -H "Authorization: Bearer $ACCESS_TOKEN" \
|
11
|
+
-H 'Content-Type: application/json' \
|
12
|
+
-H 'User-Agent: MyApp (yourname@example.com)' \
|
13
|
+
-d '{ "email": "lazaronixon@hotmail.com", "password": "secret", "password_confirmation": "secret" }' \
|
14
|
+
http://localhost:3000/sign_in
|
15
|
+
```
|
16
|
+
|
17
|
+
## API endpoints
|
18
|
+
|
19
|
+
- [Sign up](#sign-up)
|
20
|
+
- [Sign in](#sign-in)
|
21
|
+
- [Get your sessions](#get-your-sessions)
|
22
|
+
- [Get a session](#get-a-session)
|
23
|
+
- [Destroy a session](#destroy-a-session)
|
24
|
+
- [Execute sudo](#execute-sudo)
|
25
|
+
- [Update your password](#update-your-password)
|
26
|
+
- [Update your email](#update-your-email)
|
27
|
+
- [Send verification email](#send-verification-email)
|
28
|
+
- [Verify email](#verify-email)
|
29
|
+
- [Send password reset email](#send-password-reset-email)
|
30
|
+
- [Reset password](#reset-password)
|
31
|
+
|
32
|
+
## Registrations
|
33
|
+
|
34
|
+
### Sign up
|
35
|
+
|
36
|
+
* `POST /sign_up` creates a user on database.
|
37
|
+
|
38
|
+
###### Example JSON Request
|
39
|
+
|
40
|
+
``` json
|
41
|
+
{
|
42
|
+
"email": "lazaronixon@hotmail.com",
|
43
|
+
"password": "Secret1*2*3*4*5*6",
|
44
|
+
"password_confirmation": "Secret1*2*3*4*5*6"
|
45
|
+
}
|
46
|
+
```
|
47
|
+
|
48
|
+
This endpoint will return `201 Created` with the current JSON representation of the user if the creation was a success.
|
49
|
+
|
50
|
+
## Sessions
|
51
|
+
|
52
|
+
### Sign in
|
53
|
+
|
54
|
+
* `POST /sign_in` creates a session on database.
|
55
|
+
|
56
|
+
###### Example JSON Request
|
57
|
+
|
58
|
+
``` json
|
59
|
+
{
|
60
|
+
"email": "lazaronixon@hotmail.com",
|
61
|
+
"password": "Secret1*2*3*4*5*6"
|
62
|
+
}
|
63
|
+
```
|
64
|
+
|
65
|
+
This endpoint will return `201 Created` with the current JSON representation of the session if the creation was a success, also you will receive a `X-Session-Token` that you will use as your authorization token.
|
66
|
+
|
67
|
+
|
68
|
+
### Get your sessions
|
69
|
+
|
70
|
+
* `GET /sessions` will return a list of sessions.
|
71
|
+
|
72
|
+
###### Example JSON Response
|
73
|
+
|
74
|
+
``` json
|
75
|
+
[
|
76
|
+
{
|
77
|
+
"id": 2,
|
78
|
+
"user_id": 1,
|
79
|
+
"user_agent": "insomnia/2022.1.0",
|
80
|
+
"ip_address": "127.0.0.1",
|
81
|
+
"sudo_at": "2022-03-04T17:20:33.632Z",
|
82
|
+
"created_at": "2022-03-04T17:20:33.632Z",
|
83
|
+
"updated_at": "2022-03-04T17:20:33.632Z"
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"id": 1,
|
87
|
+
"user_id": 1,
|
88
|
+
"user_agent": "insomnia/2022.1.0",
|
89
|
+
"ip_address": "127.0.0.1",
|
90
|
+
"sudo_at": "2022-03-04T17:14:03.386Z",
|
91
|
+
"created_at": "2022-03-04T17:14:03.386Z",
|
92
|
+
"updated_at": "2022-03-04T17:14:03.386Z"
|
93
|
+
}
|
94
|
+
]
|
95
|
+
```
|
96
|
+
|
97
|
+
### Get a session
|
98
|
+
|
99
|
+
* `GET /sessions/1` will return the session with an ID of 1.
|
100
|
+
|
101
|
+
###### Example JSON Response
|
102
|
+
|
103
|
+
``` json
|
104
|
+
{
|
105
|
+
"id": 1,
|
106
|
+
"user_id": 1,
|
107
|
+
"user_agent": "insomnia/2022.1.0",
|
108
|
+
"ip_address": "127.0.0.1",
|
109
|
+
"sudo_at": "2022-03-04T17:14:03.386Z",
|
110
|
+
"created_at": "2022-03-04T17:14:03.386Z",
|
111
|
+
"updated_at": "2022-03-04T17:14:03.386Z"
|
112
|
+
}
|
113
|
+
```
|
114
|
+
|
115
|
+
### Destroy a session
|
116
|
+
|
117
|
+
* `DELETE /sessions/1` will destroy the session with an ID of 1.
|
118
|
+
|
119
|
+
Returns `204 No Content` if successful.
|
120
|
+
|
121
|
+
|
122
|
+
### Execute sudo
|
123
|
+
|
124
|
+
* `POST /sessions/sudo` will grant temporary access to sensitive information.
|
125
|
+
|
126
|
+
###### Example JSON Request
|
127
|
+
|
128
|
+
``` json
|
129
|
+
{
|
130
|
+
"password": "Secret1*2*3*4*5*6",
|
131
|
+
}
|
132
|
+
```
|
133
|
+
|
134
|
+
Returns `204 No Content` if successful.
|
135
|
+
|
136
|
+
## Password
|
137
|
+
|
138
|
+
### Update your password
|
139
|
+
|
140
|
+
* `PUT /password` allows changing your password.
|
141
|
+
|
142
|
+
###### Example JSON Request
|
143
|
+
|
144
|
+
``` json
|
145
|
+
{
|
146
|
+
"current_password": "Secret1*2*3*4*5*6",
|
147
|
+
"password": "NewPassword12$34$56$7",
|
148
|
+
"password_confirmation": "NewPassword12$34$56$7"
|
149
|
+
}
|
150
|
+
```
|
151
|
+
|
152
|
+
This endpoint will return 200 OK with the current JSON representation of the user if the update was a success.
|
153
|
+
|
154
|
+
## Email
|
155
|
+
|
156
|
+
### Update your email
|
157
|
+
|
158
|
+
* `PUT /identity/email` allows changing your email. **(requires sudo)**.
|
159
|
+
|
160
|
+
###### Example JSON Request
|
161
|
+
|
162
|
+
``` json
|
163
|
+
{
|
164
|
+
"email": "new_email@hey.com"
|
165
|
+
}
|
166
|
+
```
|
167
|
+
|
168
|
+
This endpoint will return 200 OK with the current JSON representation of the user if the update was a success.
|
169
|
+
|
170
|
+
## Email verification
|
171
|
+
|
172
|
+
### Send verification email
|
173
|
+
|
174
|
+
* `POST /identity/email_verification` sends an email verification with the instructions and link to proceed with the verification.
|
175
|
+
|
176
|
+
Returns `204 No Content` if successful.
|
177
|
+
|
178
|
+
### Verify email
|
179
|
+
|
180
|
+
* `GET /identity/email_verification` verify your email using a temporary token.
|
181
|
+
|
182
|
+
**Required parameters:** `email` and `token`.
|
183
|
+
|
184
|
+
Example: `/identity/email_verification?email=lazaronixon@hotmail.com&token=eyJfcmFpbHMiOnsibWVzc2FnZSI6Ik1nPT0iLCJleHAiOm51bGwsInB1ciI6InNlc3Npb24ifX0=--1a277b4a5576c6e371144a22476979a18d3e45fb8515a79e815cd4b95eb5fb6b`
|
185
|
+
|
186
|
+
Returns `204 No Content` if successful.
|
187
|
+
|
188
|
+
## Password reset
|
189
|
+
|
190
|
+
### Send password reset email
|
191
|
+
|
192
|
+
* `POST /identity/password_reset` sends a password reset email with the instructions and link to proceed reset.
|
193
|
+
|
194
|
+
Returns `204 No Content` if successful.
|
195
|
+
|
196
|
+
### Reset password
|
197
|
+
|
198
|
+
* `PUT /identity/password_reset` allows changing your password through a email token.
|
199
|
+
|
200
|
+
##### Example JSON Request
|
201
|
+
|
202
|
+
``` json
|
203
|
+
{
|
204
|
+
"password": "NewPassword12$34$56$7",
|
205
|
+
"password_confirmation": "NewPassword12$34$56$7",
|
206
|
+
"token": "eyJfcmFpbHMiOnsibWVzc2FnZSI6Ik1nPT0iLCJleHAiOm51bGwsInB1ciI6InNlc3Npb24ifX0=--1a277b4a5576c6e371144a22476979a18d3e45fb8515a79e815cd4b95eb5fb6b",
|
207
|
+
}
|
208
|
+
```
|
209
|
+
|
210
|
+
This endpoint will return 200 OK with the current JSON representation of the user if the update was a success.
|
@@ -135,6 +135,9 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
135
135
|
directory "erb/identity_mailer", "app/views/identity_mailer"
|
136
136
|
directory "erb/session_mailer", "app/views/session_mailer"
|
137
137
|
else
|
138
|
+
directory "erb/identity_mailer", "app/views/identity_mailer"
|
139
|
+
directory "erb/session_mailer", "app/views/session_mailer"
|
140
|
+
|
138
141
|
directory "erb/identity", "app/views/identity"
|
139
142
|
directory "erb/passwords", "app/views/passwords"
|
140
143
|
directory "erb/registrations", "app/views/registrations"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authentication-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.
|
4
|
+
version: 2.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- LICENSE.txt
|
27
27
|
- README.md
|
28
28
|
- Rakefile
|
29
|
+
- authentication-zero-api.md
|
29
30
|
- authentication-zero.gemspec
|
30
31
|
- lib/authentication-zero.rb
|
31
32
|
- lib/authentication_zero.rb
|