All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.nav.brukerdialog.security.oidc.OidcFeedAuthorizationModule Maven / Gradle / Ivy

There is a newer version: 1.2020.02.21_14.01-cdaccec525a6
Show newest version
package no.nav.brukerdialog.security.oidc;

import no.nav.common.auth.Subject;
import no.nav.fo.feed.common.FeedAuthorizationModule;

import java.util.List;

import static no.nav.brukerdialog.tools.Utils.getCommaSeparatedUsers;
import static no.nav.brukerdialog.tools.Utils.getSystemProperty;

public class OidcFeedAuthorizationModule implements FeedAuthorizationModule {

    @Override
    public boolean isRequestAuthorized(String feedname) {
        return no.nav.common.auth.SubjectHandler.getSubject().map(Subject::getUid).map(String::toLowerCase).map(username -> {
            String allowedUsersString = getSystemProperty(feedname + ".feed.brukertilgang");
            List allowedUsers = getCommaSeparatedUsers(allowedUsersString);
            return allowedUsers.contains(username);
        }).orElse(false);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy