This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
static key for mapping, allow to set only state namespace (#70)
* const key for mapping * owner extension refactoring
- Loading branch information
Showing
15 changed files
with
184 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package identity | ||
|
||
import ( | ||
"errors" | ||
) | ||
|
||
var ( | ||
ErrSubjectNotEqual = errors.New(`certificate subject not equal`) | ||
ErrIssuerNotEqual = errors.New(`certificate issuer not equal`) | ||
) | ||
|
||
type ( | ||
SubjectIssuer interface { | ||
GetSubject() string | ||
GetIssuer() string | ||
} | ||
) | ||
|
||
// CertEqual checks certificate equality | ||
func CertEqual(cert1, cert2 SubjectIssuer) error { | ||
|
||
if cert1 == nil || cert2 == nil { | ||
return errors.New(`certificate empty`) | ||
} | ||
if cert1.GetSubject() != cert2.GetSubject() { | ||
return ErrSubjectNotEqual | ||
} | ||
|
||
if cert1.GetIssuer() != cert2.GetIssuer() { | ||
return ErrIssuerNotEqual | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package router | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
var ErrInvalidRequest = errors.New(`invalid request`) | ||
|
||
type ( | ||
Validator interface { | ||
Validate() error | ||
} | ||
) | ||
|
||
// ValidateRequest use Validator interface and create error, allow to use error.Is(ErrInvalidRequest) | ||
func ValidateRequest(request Validator) error { | ||
if err := request.Validate(); err != nil { | ||
return fmt.Errorf(`%s: %w`, err.Error(), ErrInvalidRequest) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.