CFTunnels/src/main/java/com/hithomelabs/CFTunnels/Config/AuthoritiesToGroupMapping.java
hitanshu310 e960c5cfa5
All checks were successful
sample gradle build and test / build (pull_request) Successful in 2m24s
Final cahnges to add OIDC, setting groups and authorities
2025-09-15 00:21:49 +05:30

29 lines
1.2 KiB
Java

package com.hithomelabs.CFTunnels.Config;
import com.hithomelabs.CFTunnels.Models.Authorities;
import com.hithomelabs.CFTunnels.Models.Groups;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@Configuration
public class AuthoritiesToGroupMapping {
public Map<String, Set<GrantedAuthority>> getAuthorityForGroup(){
HashMap<String, Set<GrantedAuthority>> mappings = new HashMap<>();
mappings.put(Groups.GITEA_USER, new HashSet<>(Set.of(new SimpleGrantedAuthority(Authorities.ROLE_USER))));
mappings.put(Groups.POWER_USER, new HashSet<>(Set.of(new SimpleGrantedAuthority(Authorities.ROLE_USER))));
mappings.put(Groups.HOMELAB_DEVELOPER, new HashSet<>(Set.of(new SimpleGrantedAuthority(Authorities.ROLE_DEVELOPER))));
mappings.put(Groups.SYSTEM_ADMIN, new HashSet<>(Set.of(new SimpleGrantedAuthority(Authorities.ROLE_APPROVER), new SimpleGrantedAuthority(Authorities.ROLE_ADMIN))));
return mappings;
}
}