You've already forked lubo_comment_query
							
							WebAuthn初步接好
This commit is contained in:
		
							
								
								
									
										21
									
								
								app/Models/Casts/TrustPath.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								app/Models/Casts/TrustPath.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Models\Casts; | ||||
| 
 | ||||
| use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||||
| use Webauthn\TrustPath\TrustPathLoader; | ||||
| 
 | ||||
| class TrustPath implements CastsAttributes | ||||
| { | ||||
|     public function get($model, string $key, $value, array $attributes): ?\Webauthn\TrustPath\TrustPath | ||||
|     { | ||||
|         return $value !== null | ||||
|             ? TrustPathLoader::loadTrustPath(json_decode($value, true)) | ||||
|             : null; | ||||
|     } | ||||
| 
 | ||||
|     public function set($model, string $key, $value, array $attributes) | ||||
|     { | ||||
|         return json_encode($value); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										24
									
								
								app/Models/Casts/Uuid.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								app/Models/Casts/Uuid.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Models\Casts; | ||||
| 
 | ||||
| use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||||
| use Ramsey\Uuid\Uuid as UuidConvert; | ||||
| use Ramsey\Uuid\UuidInterface; | ||||
| 
 | ||||
| class Uuid implements CastsAttributes | ||||
| { | ||||
|     public function get($model, string $key, $value, array $attributes): ?UuidInterface | ||||
|     { | ||||
|         if ($value !== null && UuidConvert::isValid($value)) { | ||||
|             return UuidConvert::fromString($value); | ||||
|         } | ||||
| 
 | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     public function set($model, string $key, $value, array $attributes): ?string | ||||
|     { | ||||
|         return (string) $value; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										19
									
								
								app/Models/Casts/WebAuthnBase64.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								app/Models/Casts/WebAuthnBase64.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Models\Casts; | ||||
| 
 | ||||
| use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||||
| use function Safe\base64_decode; | ||||
| 
 | ||||
| class WebAuthnBase64 implements CastsAttributes | ||||
| { | ||||
|     public function get($model, string $key, $value, array $attributes): ?string | ||||
|     { | ||||
|         return $value !== null ? base64_decode($value) : null; | ||||
|     } | ||||
| 
 | ||||
|     public function set($model, string $key, $value, array $attributes) | ||||
|     { | ||||
|         return $value !== null ? base64_encode($value) : null; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user