hudi
hudi

Reputation: 16525

How to implement external auth in wicket

I want to login to my application using some external auth like facebook google or steam.

I found library: org.pac4j which support some of this login but I dot know how I can integrate it with wicket. After successful auth I want to signIn into my session.

public class WicketSteamAuthenticator extends SteamAuthenticator {

    public WicketSteamAuthenticator(SteamClient client) {
        super(client);
    }

    @Override
    public void validate(OpenIdCredentials credentials, WebContext context) {
        super.validate(credentials, context);
        AuthenticatedWebSession.get().signIn(credentials.getUserProfile().getId(), null);
    }
}

Problem is that this security filters are before wicket-filter which means I got exception:

There is no application attached to current thread wicket session

is there already some example how to use wicket with spring security and with some external auth ?

Upvotes: 3

Views: 320

Answers (1)

Andrea Del Bene
Andrea Del Bene

Reputation: 2511

I don't have a deep knowledge of org.pac4j but it's my understanding that it works with callback endpoints that can be used also to save user profile in Session. So instead of invoking signIn on AuthenticatedWebSession I would create a custom implementation of class AbstractAuthenticatedWebSession which is able to retrieve the user profile previously saved by org.pac4j and decide if user is signed id and which roles it has. Hope this could help you.

Upvotes: 3

Related Questions