-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Middleware for authentication by access key and signed data #44
Conversation
Anyone know why Travis is spitting out the following error? All
|
@ChristopherRabotin can you pull the last changes? |
"github.com/ChristopherRabotin/gin-contrib/signedauth" does not exist in your master branch. and github.com/ChristopherRabotin/gin-contrib/signedauth should be changed to "github.com/gin-gonic/contrib/signedauth Go sometimes sucks. |
|
||
// ContextValue returns the value to store in Gin's context at ContextKey(). | ||
func (mgr StrictSHA1Manager) ContextValue(access string) interface{} { | ||
if access == "my_access_key" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify your question so I can implement the changes you'd like so this PR can be merged? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ContextValue
function allows to set a given value into the context provided an access string, and is only called once the signature was proven as valid. Hence, this function takes, as input, some uniquely user-identifiable string and sets a given value in the context for subsequent calls in the context. For example if user with ID 5 has access key user_id_5_access
with a given secret key, and passed all the validation steps for the request, then this function will be called with user_id_5_access
as its only parameter, and can set 5
in the user
variable of the context. This is an example of course because everything is configurable in this plugin, as explained in the README.
@manucorporat , the build is failing from an auth failure. Any idea on the reasons?
|
@ChristopherRabotin "github.com/gin-gonic/gin-contrib" does not exist. |
@manucorporat sorry, I wasn't awake enough when I wrote that comment. Fixing this now. |
@ChristopherRabotin do not worry too much about travis ci, I will review it. |
@manucorporat let me know if I can help for the review. |
@manucorporat , I hope to use the code in this PR on a production system in the next week, so could you merge it in? Let me know how I can help you in reviewing this PR, maybe in explaining parts of the code for example. Thank you in advance. |
This build just failed because of issues unrelated to this PR.
|
Superseded by #56 . |
Implements #43 .
Below is the README of this middleware.
The signedauth middleware
Purpose
Allows to protect routes with a signature based authentication.
Features
Quite customizable, including the following custom settings.
SignedAuthManager.HashFunction
.SignedAuthManager.AuthHeaderPrefix
.SignedAuthManager.SecretKey
.SignedAuthManager.SecretKey
.SignedAuthManager.DataToSign
.SignedAuthManager.AuthHeaderRequired
.SignedAuthManager.ContextKey
and cf.SignedAuthManager.ContextValue
.Examples
Refer to the tests and the example directory.