How do I call MitreID OIDC server?

2019-08-17 15:29发布

问题:

I am using the Spring Boot MitreID OIDC application from here. This runs OK and I can login but there are no other options available to me:

I am trying to access it using simple-web-app. In simple-web-app I try to login using URI: http://localhost:8080/openid-connect-server-webapp/. This gives:

WARN : org.mitre.openid.connect.client.service.impl.DynamicServerConfigurationService -
 Couldn't load configuration for http://localhost:8080/openid-connect-server-webapp/: 
com.google.common.util.concurrent.UncheckedExecutionException: 
org.springframework.web.client.HttpClientErrorException: 404 
ERROR: org.mitre.openid.connect.client.OIDCAuthenticationFilter - No server 
configuration found for issuer: http://localhost:8080/openid-connect-server-webapp/

EDIT: when I try http://localhost:8080 I get:

    WARN : org.mitre.openid.connect.client.service.impl.WebfingerIssuerService - Webfinger 
endpoint MUST use the https URI scheme, overriding by configuration
ERROR: org.mitre.openid.connect.client.OIDCAuthenticationFilter - No client
 configuration found for issuer: http://localhost:8080/

Can anyone point me in the right direction?

FYI simple-web-app has only one java class:

package org.mitre.web;

import java.security.Principal;
import java.util.Locale;
import java.util.Set;

import javax.annotation.Resource;

import org.mitre.openid.connect.client.OIDCAuthenticationFilter;
import org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController {

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

    // filter reference so we can get class names and things like that.
    @Autowired
    private OIDCAuthenticationFilter filter;

    @Resource(name = "namedAdmins")
    private Set<SubjectIssuerGrantedAuthority> admins;

    /**
     * Simply selects the home view to render by returning its name.
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String home(Locale locale, Model model, Principal p) {

        model.addAttribute("issuerServiceClass", filter.getIssuerService().getClass().getSimpleName());
        model.addAttribute("serverConfigurationServiceClass", filter.getServerConfigurationService().getClass().getSimpleName());
        model.addAttribute("clientConfigurationServiceClass", filter.getClientConfigurationService().getClass().getSimpleName());
        model.addAttribute("authRequestOptionsServiceClass", filter.getAuthRequestOptionsService().getClass().getSimpleName());
        model.addAttribute("authRequestUriBuilderClass", filter.getAuthRequestUrlBuilder().getClass().getSimpleName());

        model.addAttribute("admins", admins);

        return "home";
    }

    @RequestMapping("/user")
    @PreAuthorize("hasRole('ROLE_USER')")
    public String user(Principal p) {
        return "user";
    }

    @RequestMapping("/open")
    public String open(Principal p) {
        return "open";
    }

    @RequestMapping("/admin")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public String admin(Model model, Principal p) {

        model.addAttribute("admins", admins);

        return "admin";
    }

    @RequestMapping("/login")
    public String login(Principal p) {
        return "login";
    }

}

回答1:

MitreID is serving on root but sample app is calling on /openid-connect-server-webapp/ You'll want to change your sample app to point to the proper issuer....http://localhost:8080/ (maybe in the application.properties of your sample app?) Or your MitreID server is not configured properly (possibly for issuer property)

See http://localhost:8080/.well-known/openid-configuration for all the endpoints your sample app would hit