fix(config): improve container detection (#420)

fix(config): detect container
This commit is contained in:
ze0s 2022-08-21 18:21:43 +02:00 committed by GitHub
parent 8457222b28
commit 765215270a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 42 deletions

View file

@ -43,7 +43,7 @@ func (s *service) List(ctx context.Context) ([]domain.APIKey, error) {
}
func (s *service) Store(ctx context.Context, key *domain.APIKey) error {
key.Key = generateSecureToken(16)
key.Key = GenerateSecureToken(16)
if err := s.repo.Store(ctx, key); err != nil {
return err
@ -82,7 +82,7 @@ func (s *service) ValidateAPIKey(ctx context.Context, key string) bool {
return false
}
func generateSecureToken(length int) string {
func GenerateSecureToken(length int) string {
b := make([]byte, length)
if _, err := rand.Read(b); err != nil {
return ""