|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +namespace Pdsinterop\Solid\Auth\Enum\OAuth2; |
| 4 | + |
| 5 | +/** |
| 6 | + * OAuth Authorization Endpoint Response Types |
| 7 | + * |
| 8 | + * The OAuth 2.0 specification allows for registration of space-separated |
| 9 | + * response_type parameter values. If a Response Type contains one of more space |
| 10 | + * characters (%20), it is compared as a space-delimited list of values in which |
| 11 | + * the order of values does not matter. |
| 12 | + * |
| 13 | + * The Response Type request parameter response_type informs the Authorization |
| 14 | + * Server of the desired authorization processing flow, including what |
| 15 | + * parameters are returned from the endpoints used. |
| 16 | + * |
| 17 | + * Each Response Type value also defines a default Response Mode mechanism to be |
| 18 | + * used, if no Response Mode is specified using the request parameter. |
| 19 | + * |
| 20 | + * Specification Document(s): https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html |
| 21 | + * |
| 22 | + * If omitted, the default is that the Client will use only the code Response Type |
| 23 | + * |
| 24 | + * @see https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#endpoint |
| 25 | + */ |
| 26 | +class ResponseType |
| 27 | +{ |
| 28 | + public const CODE = Parameter::CODE; |
| 29 | + |
| 30 | + public const DEFAULT = self::CODE; |
| 31 | + |
| 32 | + /** |
| 33 | + * When supplied as the response_type parameter in an OAuth 2.0 |
| 34 | + * Authorization Request, a successful response MUST include the parameter |
| 35 | + * id_token. The Authorization Server SHOULD NOT return an OAuth 2.0 |
| 36 | + * Authorization Code, Access Token, or Access Token Type in a successful |
| 37 | + * response to the grant request. If a redirect_uri is supplied, the User |
| 38 | + * Agent SHOULD be redirected there after granting or denying access. |
| 39 | + * The request MAY include a state parameter, and if so, the Authorization |
| 40 | + * Server MUST echo its value as a response parameter when issuing either a |
| 41 | + * successful response or an error response. The default Response Mode for |
| 42 | + * this Response Type is the fragment encoding and the query encoding MUST |
| 43 | + * NOT be used. Both successful and error responses SHOULD be returned using |
| 44 | + * the supplied Response Mode, or if none is supplied, using the default |
| 45 | + * Response Mode. |
| 46 | + */ |
| 47 | + public const ID_TOKEN = 'id_token'; |
| 48 | + |
| 49 | + /** |
| 50 | + * When supplied as the response_type parameter in an OAuth 2.0 |
| 51 | + * Authorization Request, the Authorization Server SHOULD NOT return an |
| 52 | + * OAuth 2.0 Authorization Code, Access Token, Access Token Type, or ID |
| 53 | + * Token in a successful response to the grant request. If a redirect_uri is |
| 54 | + * supplied, the User Agent SHOULD be redirected there after granting or |
| 55 | + * denying access. The request MAY include a state parameter, and if so, the |
| 56 | + * Authorization Server MUST echo its value as a response parameter when |
| 57 | + * issuing either a successful response or an error response. The default |
| 58 | + * Response Mode for this Response Type is the query encoding. Both |
| 59 | + * successful and error responses SHOULD be returned using the supplied |
| 60 | + * Response Mode, or if none is supplied, using the default Response Mode. |
| 61 | + */ |
| 62 | + public const NONE = 'none'; |
| 63 | + |
| 64 | + public const TOKEN = 'token'; |
| 65 | + |
| 66 | + /*/ Multiple Valued Response Types /*/ |
| 67 | + |
| 68 | + /** |
| 69 | + * When supplied as the value for the response_type parameter, a successful |
| 70 | + * response MUST include both an Authorization Code and an id_token. The |
| 71 | + * default Response Mode for this Response Type is the fragment encoding and |
| 72 | + * the query encoding MUST NOT be used. Both successful and error responses |
| 73 | + * SHOULD be returned using the supplied Response Mode, or if none is |
| 74 | + * supplied, using the default Response Mode. |
| 75 | + */ |
| 76 | + public const CODE_ID_TOKEN = [ |
| 77 | + self::CODE, |
| 78 | + self::ID_TOKEN, |
| 79 | + ]; |
| 80 | + |
| 81 | + /** |
| 82 | + * When supplied as the value for the response_type parameter, a successful |
| 83 | + * response MUST include an Authorization Code, an id_token, an Access Token, |
| 84 | + * and an Access Token Type. The default Response Mode for this Response |
| 85 | + * Type is the fragment encoding and the query encoding MUST NOT be used. |
| 86 | + * Both successful and error responses SHOULD be returned using the supplied |
| 87 | + * Response Mode, or if none is supplied, using the default Response Mode. |
| 88 | + */ |
| 89 | + public const CODE_ID_TOKEN_TOKEN = [ |
| 90 | + self::CODE, |
| 91 | + self::ID_TOKEN, |
| 92 | + self::TOKEN, |
| 93 | + ]; |
| 94 | + |
| 95 | + /** |
| 96 | + * When supplied as the value for the response_type parameter, a successful |
| 97 | + * response MUST include an Access Token, an Access Token Type, and an |
| 98 | + * Authorization Code. The default Response Mode for this Response Type is |
| 99 | + * the fragment encoding and the query encoding MUST NOT be used. Both |
| 100 | + * successful and error responses SHOULD be returned using the supplied |
| 101 | + * Response Mode, or if none is supplied, using the default Response Mode. |
| 102 | + */ |
| 103 | + public const CODE_TOKEN = [ |
| 104 | + self::CODE, |
| 105 | + self::TOKEN, |
| 106 | + ]; |
| 107 | + |
| 108 | + /** |
| 109 | + * When supplied as the value for the response_type parameter, a successful |
| 110 | + * response MUST include an Access Token, an Access Token Type, and an |
| 111 | + * id_token. The default Response Mode for this Response Type is the fragment |
| 112 | + * encoding and the query encoding MUST NOT be used. Both successful and |
| 113 | + * error responses SHOULD be returned using the supplied Response Mode, or |
| 114 | + * if none is supplied, using the default Response Mode. |
| 115 | + */ |
| 116 | + public const ID_TOKEN_TOKEN = [ |
| 117 | + self::ID_TOKEN, |
| 118 | + self::TOKEN, |
| 119 | + ]; |
| 120 | +} |
0 commit comments