Skip to content

Commit 504f7f4

Browse files
committed
Add Enum class representing OAuth2 Grant Types.
1 parent 64c50dd commit 504f7f4

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

src/Enum/OAuth2/GrantType.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Pdsinterop\Solid\Auth\Enum\OAuth2;
4+
5+
/**
6+
* Enum class representing valid values for Grant Types
7+
*
8+
* The values are taken ad-verbatim from RFC6749, they are used as identifiers
9+
* by the League OAuth2 Server and Client libraries.
10+
*
11+
* Any advise whether or not to use specific grants is taken directly from the
12+
* OAuth 2.0 Security Best Current Practices:
13+
* https://tools.ietf.org/html/draft-ietf-oauth-security-topics
14+
*/
15+
class GrantType
16+
{
17+
/**
18+
* RFC6749 - OAuth2: Authorization Code Grant
19+
* RFC7636 - Proof Key for Code Exchange (PKCE)
20+
*
21+
* It is recommended that all clients use the PKCE extension with this flow
22+
* as well to provide better security.
23+
*/
24+
public const AUTH_CODE = 'authorization_code';
25+
26+
// RFC6749 - OAuth2: Client Credentials Grant
27+
public const CLIENT_CREDENTIALS = 'client_credentials';
28+
29+
// RFC8628: OAuth 2.0 Device Authorization Grant
30+
public const DEVICE_CODE = "urn:ietf:params:oauth:grant-type:device_code";
31+
32+
/**
33+
* RFC6749 - OAuth2: Implicit Grant
34+
*
35+
* @deprecated Please use Authorization Code flow with PKCE instead!
36+
*/
37+
public const IMPLICIT = 'implicit';
38+
39+
/**
40+
* RFC6749 - OAuth2: Resource Owner Password Credentials Grant
41+
*
42+
* @deprecated
43+
*/
44+
public const PASSWORD = 'password';
45+
46+
// RFC6749 - OAuth2: Refresh Token Grant
47+
public const REFRESH_TOKEN = 'refresh_token';
48+
49+
}

0 commit comments

Comments
 (0)