customize auth stategy detector
skreib opened this issue · comments
the private method is used for detecting auth strategies
def detect_strategy(auth)
strategy = auth.env["omniauth.auth"]["provider"] if auth.env["omniauth.auth"]
strategy ||= auth.winning_strategy.class.name.split("::").last.underscore if auth.winning_strategy
strategy ||= "database_authenticatable"
strategy
end
The problem appears with the device-jwt gem due to incorrect parsing.
For example, Warden::JWTAuth::Strategy
transforms into strategy
.
Expected result:
Warden::JWTAuth::Strategy
=> jwtauth_strategy
or
Warden::JWTAuth::Strategy
=> jwtauth
Can some custom strategy parser be added, for example, by initializer config?
Hi @skreib, you can use transform_method
for this.
AuthTrail.transform_method = lambda do |data, request|
# customize as needed
data[:strategy] = request.env["warden"].winning_strategy.class.name
end