Query shiro to build login form

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Query shiro to build login form

volumeint
At runtime, I would like to query the shiro library to determine how I should prompt my users to login.  If I have any "Direct" realms (jdbc, ldap), I would want to show a username/password form.  If I have "Indirect" realms (oauth, cas), I would want to provide buttons for "Login using external-service-x".  If shiro has been configured with both Direct and Indirect realms, I want my login form to show both options, buttons and a form. Is this possible directly from Shiro?

I know how to get the list of configured Realms, but is there a way to determine if a realm is Direct or Indirect?  I'm hoping to avoid someRealm.getClass().getName().equals(KNOWN_INDIRECT_REALM_IMPL).
Reply | Threaded
Open this post in threaded view
|

Re: Query shiro to build login form

Brian Demers
Cool idea!

Take a look at the 'supports()' method https://shiro.apache.org/static/1.3.2/apidocs/org/apache/shiro/realm/AuthenticatingRealm.html#supports-org.apache.shiro.authc.AuthenticationToken-

You could loop through your collection of realms and pass a Username Password token to them.

-Brian

On Tue, Jun 13, 2017 at 4:36 PM, volumeint <[hidden email]> wrote:
At runtime, I would like to query the shiro library to determine how I should
prompt my users to login.  If I have any "Direct" realms (jdbc, ldap), I
would want to show a username/password form.  If I have "Indirect" realms
(oauth, cas), I would want to provide buttons for "Login using
/external-service-x/".  If shiro has been configured with both Direct and
Indirect realms, I want my login form to show both options, buttons and a
form. Is this possible directly from Shiro?

I know how to get the list of configured Realms, but is there a way to
determine if a realm is Direct or Indirect?  I'm hoping to avoid
someRealm.getClass().getName().equals(KNOWN_INDIRECT_REALM_IMPL).




--
View this message in context: http://shiro-user.582556.n2.nabble.com/Query-shiro-to-build-login-form-tp7581652.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Query shiro to build login form

volumeint
Great suggestion!  Using that approach, I will know if I should show the username/password form or not.  I can assume that if I have a realm that does not support UsernamePasswordToken that it must be an Indirect realm and I should show buttons/links.

I don't think I'll be able to introspect the Indirect realm to get enough information to generate the "Login using x" buttons (I would want to change color and icons to match the provider), but I can augment that via my own configuration. 

Thanks!

On Tue, Jun 13, 2017 at 6:00 PM, Brian Demers [via Shiro User] <[hidden email]> wrote:
Cool idea!

Take a look at the 'supports()' method https://shiro.apache.org/static/1.3.2/apidocs/org/apache/shiro/realm/AuthenticatingRealm.html#supports-org.apache.shiro.authc.AuthenticationToken-

You could loop through your collection of realms and pass a Username Password token to them.

-Brian

On Tue, Jun 13, 2017 at 4:36 PM, volumeint <[hidden email]> wrote:
At runtime, I would like to query the shiro library to determine how I should
prompt my users to login.  If I have any "Direct" realms (jdbc, ldap), I
would want to show a username/password form.  If I have "Indirect" realms
(oauth, cas), I would want to provide buttons for "Login using
/external-service-x/".  If shiro has been configured with both Direct and
Indirect realms, I want my login form to show both options, buttons and a
form. Is this possible directly from Shiro?

I know how to get the list of configured Realms, but is there a way to
determine if a realm is Direct or Indirect?  I'm hoping to avoid
someRealm.getClass().getName().equals(KNOWN_INDIRECT_REALM_IMPL).




--
View this message in context: http://shiro-user.582556.n2.nabble.com/Query-shiro-to-build-login-form-tp7581652.html
Sent from the Shiro User mailing list archive at Nabble.com.




If you reply to this email, your message will be added to the discussion below:
http://shiro-user.582556.n2.nabble.com/Query-shiro-to-build-login-form-tp7581652p7581653.html
To unsubscribe from Query shiro to build login form, click here.
NAML