如何调用MitreID OIDC服务器?

时间:2018-12-19 12:38:13

标签: java spring-boot oidc mitreid-connect

我正在使用here中的Spring Boot MitreID OIDC应用程序。运行正常,我可以登录,但是没有其他可用选项: enter image description here

我正在尝试使用simple-web-app访问它。在simple-web-app中,我尝试使用URI登录:http://localhost:8080/openid-connect-server-webapp/。这给出了:

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/

编辑:当我尝试http://localhost:8080时,我得到:

    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/

有人能指出我正确的方向吗?

FYI simple-web-app只有一个Java类:

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 个答案:

答案 0 :(得分:1)

MitreID在根服务器上提供,但示例应用程序在/ openid-connect-server-webapp /上调用 您需要更改示例应用程序以使其指向正确的发行者。...http://localhost:8080/(可能在示例应用程序的application.properties中?)或者您的MitreID服务器配置不正确(可能是针对发行者属性) )

请参见http://localhost:8080/.well-known/openid-configuration,了解示例应用程序可以访问的所有端点