Skip to content

Commit ffb9004

Browse files
committed
init
0 parents  commit ffb9004

File tree

96 files changed

+4264
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+4264
-0
lines changed

Auth/Access/Authorizable.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace IgniteKit\Backports\Contracts\Auth\Access;
4+
5+
interface Authorizable
6+
{
7+
/**
8+
* Determine if the entity has a given ability.
9+
*
10+
* @param string $ability
11+
* @param array|mixed $arguments
12+
* @return bool
13+
*/
14+
public function can($ability, $arguments = []);
15+
}

Auth/Access/Gate.php

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?php
2+
3+
namespace IgniteKit\Backports\Contracts\Auth\Access;
4+
5+
interface Gate
6+
{
7+
/**
8+
* Determine if a given ability has been defined.
9+
*
10+
* @param string $ability
11+
* @return bool
12+
*/
13+
public function has($ability);
14+
15+
/**
16+
* Define a new ability.
17+
*
18+
* @param string $ability
19+
* @param callable|string $callback
20+
* @return $this
21+
*/
22+
public function define($ability, $callback);
23+
24+
/**
25+
* Define a policy class for a given class type.
26+
*
27+
* @param string $class
28+
* @param string $policy
29+
* @return $this
30+
*/
31+
public function policy($class, $policy);
32+
33+
/**
34+
* Register a callback to run before all Gate checks.
35+
*
36+
* @param callable $callback
37+
* @return $this
38+
*/
39+
public function before(callable $callback);
40+
41+
/**
42+
* Register a callback to run after all Gate checks.
43+
*
44+
* @param callable $callback
45+
* @return $this
46+
*/
47+
public function after(callable $callback);
48+
49+
/**
50+
* Determine if the given ability should be granted for the current user.
51+
*
52+
* @param string $ability
53+
* @param array|mixed $arguments
54+
* @return bool
55+
*/
56+
public function allows($ability, $arguments = []);
57+
58+
/**
59+
* Determine if the given ability should be denied for the current user.
60+
*
61+
* @param string $ability
62+
* @param array|mixed $arguments
63+
* @return bool
64+
*/
65+
public function denies($ability, $arguments = []);
66+
67+
/**
68+
* Determine if all of the given abilities should be granted for the current user.
69+
*
70+
* @param iterable|string $abilities
71+
* @param array|mixed $arguments
72+
* @return bool
73+
*/
74+
public function check($abilities, $arguments = []);
75+
76+
/**
77+
* Determine if any one of the given abilities should be granted for the current user.
78+
*
79+
* @param iterable|string $abilities
80+
* @param array|mixed $arguments
81+
* @return bool
82+
*/
83+
public function any($abilities, $arguments = []);
84+
85+
/**
86+
* Determine if the given ability should be granted for the current user.
87+
*
88+
* @param string $ability
89+
* @param array|mixed $arguments
90+
* @return \IgniteKit\Backports\Auth\Access\Response
91+
*
92+
* @throws \IgniteKit\Backports\Auth\Access\AuthorizationException
93+
*/
94+
public function authorize($ability, $arguments = []);
95+
96+
/**
97+
* Get the raw result from the authorization callback.
98+
*
99+
* @param string $ability
100+
* @param array|mixed $arguments
101+
* @return mixed
102+
*/
103+
public function raw($ability, $arguments = []);
104+
105+
/**
106+
* Get a policy instance for a given class.
107+
*
108+
* @param object|string $class
109+
* @return mixed
110+
*
111+
* @throws \InvalidArgumentException
112+
*/
113+
public function getPolicyFor($class);
114+
115+
/**
116+
* Get a guard instance for the given user.
117+
*
118+
* @param \IgniteKit\Backports\Contracts\Auth\Authenticatable|mixed $user
119+
* @return static
120+
*/
121+
public function forUser($user);
122+
123+
/**
124+
* Get all of the defined abilities.
125+
*
126+
* @return array
127+
*/
128+
public function abilities();
129+
}

Auth/Authenticatable.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace IgniteKit\Backports\Contracts\Auth;
4+
5+
interface Authenticatable
6+
{
7+
/**
8+
* Get the name of the unique identifier for the user.
9+
*
10+
* @return string
11+
*/
12+
public function getAuthIdentifierName();
13+
14+
/**
15+
* Get the unique identifier for the user.
16+
*
17+
* @return mixed
18+
*/
19+
public function getAuthIdentifier();
20+
21+
/**
22+
* Get the password for the user.
23+
*
24+
* @return string
25+
*/
26+
public function getAuthPassword();
27+
28+
/**
29+
* Get the token value for the "remember me" session.
30+
*
31+
* @return string
32+
*/
33+
public function getRememberToken();
34+
35+
/**
36+
* Set the token value for the "remember me" session.
37+
*
38+
* @param string $value
39+
* @return void
40+
*/
41+
public function setRememberToken($value);
42+
43+
/**
44+
* Get the column name for the "remember me" token.
45+
*
46+
* @return string
47+
*/
48+
public function getRememberTokenName();
49+
}

Auth/CanResetPassword.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace IgniteKit\Backports\Contracts\Auth;
4+
5+
interface CanResetPassword
6+
{
7+
/**
8+
* Get the e-mail address where password reset links are sent.
9+
*
10+
* @return string
11+
*/
12+
public function getEmailForPasswordReset();
13+
14+
/**
15+
* Send the password reset notification.
16+
*
17+
* @param string $token
18+
* @return void
19+
*/
20+
public function sendPasswordResetNotification($token);
21+
}

Auth/Factory.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace IgniteKit\Backports\Contracts\Auth;
4+
5+
interface Factory
6+
{
7+
/**
8+
* Get a guard instance by name.
9+
*
10+
* @param string|null $name
11+
* @return mixed
12+
*/
13+
public function guard($name = null);
14+
15+
/**
16+
* Set the default guard the factory should serve.
17+
*
18+
* @param string $name
19+
* @return void
20+
*/
21+
public function shouldUse($name);
22+
}

Auth/Guard.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace IgniteKit\Backports\Contracts\Auth;
4+
5+
interface Guard
6+
{
7+
/**
8+
* Determine if the current user is authenticated.
9+
*
10+
* @return bool
11+
*/
12+
public function check();
13+
14+
/**
15+
* Determine if the current user is a guest.
16+
*
17+
* @return bool
18+
*/
19+
public function guest();
20+
21+
/**
22+
* Get the currently authenticated user.
23+
*
24+
* @return \IgniteKit\Backports\Contracts\Auth\Authenticatable|null
25+
*/
26+
public function user();
27+
28+
/**
29+
* Get the ID for the currently authenticated user.
30+
*
31+
* @return int|string|null
32+
*/
33+
public function id();
34+
35+
/**
36+
* Validate a user's credentials.
37+
*
38+
* @param array $credentials
39+
* @return bool
40+
*/
41+
public function validate(array $credentials = []);
42+
43+
/**
44+
* Set the current user.
45+
*
46+
* @param \IgniteKit\Backports\Contracts\Auth\Authenticatable $user
47+
* @return void
48+
*/
49+
public function setUser(Authenticatable $user);
50+
}

Auth/MustVerifyEmail.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace IgniteKit\Backports\Contracts\Auth;
4+
5+
interface MustVerifyEmail
6+
{
7+
/**
8+
* Determine if the user has verified their email address.
9+
*
10+
* @return bool
11+
*/
12+
public function hasVerifiedEmail();
13+
14+
/**
15+
* Mark the given user's email as verified.
16+
*
17+
* @return bool
18+
*/
19+
public function markEmailAsVerified();
20+
21+
/**
22+
* Send the email verification notification.
23+
*
24+
* @return void
25+
*/
26+
public function sendEmailVerificationNotification();
27+
}

Auth/PasswordBroker.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
namespace IgniteKit\Backports\Contracts\Auth;
4+
5+
use Closure;
6+
7+
interface PasswordBroker
8+
{
9+
/**
10+
* Constant representing a successfully sent reminder.
11+
*
12+
* @var string
13+
*/
14+
const RESET_LINK_SENT = 'passwords.sent';
15+
16+
/**
17+
* Constant representing a successfully reset password.
18+
*
19+
* @var string
20+
*/
21+
const PASSWORD_RESET = 'passwords.reset';
22+
23+
/**
24+
* Constant representing the user not found response.
25+
*
26+
* @var string
27+
*/
28+
const INVALID_USER = 'passwords.user';
29+
30+
/**
31+
* Constant representing an invalid password.
32+
*
33+
* @var string
34+
*/
35+
const INVALID_PASSWORD = 'passwords.password';
36+
37+
/**
38+
* Constant representing an invalid token.
39+
*
40+
* @var string
41+
*/
42+
const INVALID_TOKEN = 'passwords.token';
43+
44+
/**
45+
* Send a password reset link to a user.
46+
*
47+
* @param array $credentials
48+
* @return string
49+
*/
50+
public function sendResetLink(array $credentials);
51+
52+
/**
53+
* Reset the password for the given token.
54+
*
55+
* @param array $credentials
56+
* @param \Closure $callback
57+
* @return mixed
58+
*/
59+
public function reset(array $credentials, Closure $callback);
60+
61+
/**
62+
* Set a custom password validator.
63+
*
64+
* @param \Closure $callback
65+
* @return void
66+
*/
67+
public function validator(Closure $callback);
68+
69+
/**
70+
* Determine if the passwords match for the request.
71+
*
72+
* @param array $credentials
73+
* @return bool
74+
*/
75+
public function validateNewPassword(array $credentials);
76+
}

0 commit comments

Comments
 (0)