You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if a user could define his or hers own authentication strategy.
We could create an abstract class like:
class HTTPBasicAuth
abstract class AuthenticationStrategy
abstract def authorize?(username : String, password : String): String?
end
end
Then a user could write his own implementation:
class MongoAuthenticationStrategy < AuthenticationStrategy
def authorize?(username : String, password : String): String?
# find a user in database and return his ID if it exists
end
end
In order to keep backward compatibility we could add another contructor to the HttpBasicAuth
def initialize(@strategy : AuthenticationStrategy)
initialize({} of String => String)
end
and then in the authorize? method perform a check:
if strategy = @strategy
strategy.authorize?(username, password)
else
@credentials.authorize?(username, password)
end
What do you think? If you like the idea I can make a pull request and leave it for you to review 😄
The text was updated successfully, but these errors were encountered:
It would be nice if a user could define his or hers own authentication strategy.
We could create an abstract class like:
Then a user could write his own implementation:
In order to keep backward compatibility we could add another contructor to the
HttpBasicAuth
and then in the
authorize?
method perform a check:What do you think? If you like the idea I can make a pull request and leave it for you to review 😄
The text was updated successfully, but these errors were encountered: