-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #369 from elisasre/feat/auth-refactor
Combine Add and Rotate keys
- Loading branch information
Showing
10 changed files
with
153 additions
and
142 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
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 httputil | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"strings" | ||
) | ||
|
||
func IsHTTPS(r *http.Request) bool { | ||
const protoHTTPS = "https" | ||
switch { | ||
case r.URL.Scheme == protoHTTPS: | ||
return true | ||
case r.TLS != nil: | ||
return true | ||
case strings.HasPrefix(strings.ToLower(r.Proto), protoHTTPS): | ||
return true | ||
case r.Header.Get("X-Forwarded-Proto") == protoHTTPS: | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
func (e ErrorResponse) Error() string { | ||
return fmt.Sprintf("%d: %s", e.Code, e.Message) | ||
} | ||
|
||
// ErrorResponse provides HTTP error response. | ||
type ErrorResponse struct { | ||
Code uint `json:"code,omitempty" example:"400"` | ||
Message string `json:"message" example:"Bad request"` | ||
ErrorType string `json:"error_type,omitempty" example:"invalid_scope"` | ||
} |
Oops, something went wrong.